Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Open drawer button doesn't work when clicked on the edge #3086

Closed
tkgregory opened this issue Jun 17, 2024 · 5 comments
Closed

bug: Open drawer button doesn't work when clicked on the edge #3086

tkgregory opened this issue Jun 17, 2024 · 5 comments

Comments

@tkgregory
Copy link

tkgregory commented Jun 17, 2024

What version of daisyUI are you using?

4.12.2

Which browsers are you seeing the problem on?

Brave (Chromium)

Reproduction URL

https://daisyui.com/components/drawer/

Describe your issue

The drawer component has a button that normally opens the drawer when clicked.

When you click at the very edge of the button, the button shrinks as if clicked, but the drawer does not open. This happens every time.

2024-06-17.08-52-08.mp4

I would expect the drawer to open wherever you click on the button.

Copy link

Thank you @tkgregory for reporting issues. It helps daisyUI a lot 💚
I'll be working on issues one by one. I will help with this one as soon as a I find a solution.
In the meantime providing more details and reproduction links would be helpful.

@saadeghi
Copy link
Owner

It's not about the drawer, it's about the button click animation.
If you click normally it opens but if you click+hold+release on the edge of the button, the button shrinks (the click animation) and when it shrinks, you're not actually clicking the button, it's releasing the click outside of the button.
This doesn't happen normally. I mean why would someone click the very edge pixel of a button? 😅

To disable the animation:
You can disable the button click shrink animation using no-animation class name:

<button class="btn no-animation">I don't have click animation</button>

Or from the theme config:

  daisyui: {
    themes: [
      {
        light: {
          ...require("daisyui/src/theming/themes")["light"],
          "--btn-focus-scale": "1",
        },
      },
    ],
  },

Let me know if you have a question.

@tkgregory
Copy link
Author

Thanks for the quick reply @saadeghi . So because the button shrinks on click, the cursor is no longer above the button on release. That means the relevant event doesn't fire.

I get this is why it's happening, but could it be useful to fire the event anyway?

I mean, from the user perspective they think they clicked the button, right? Should they know the button shrinks before they click on it and therefore not click at the edge?

Just wondering what is best from user's perspective.

@saadeghi
Copy link
Owner

So because the button shrinks on click, the cursor is no longer above the button on release. That means the relevant event doesn't fire.

Yes, only if the click position is at the very edge pixel of the button which is not common, and if your current daisyUI theme has a --btn-focus-scale shrink animation.

but could it be useful to fire the event anyway?

daisyUI is not doing anything about mouse events. daisyUI is just CSS. This happens because mouse down is on the button, the button has a shrink animation and if the click is on the edge of the button, the mouse up is not on the button, so for the browser, it's more like dragging event than a click event since the mouse down and mouse up position is not on the same element.

We have this --btn-focus-scale on built-in daisyUI themes because the shrinking animation of button gives the a natural feeling of a button being pushed. It's for the visual and better user experience.

Just wondering what is best from user's perspective.

If you ask my opinion, it's not a common thing for users to click on a edge border of a button and expect it to work. According to UX heatmaps, users usually click on the middle of the button or anywhere on the button text (which is in the middle). If they click on the edge, it's usually not intentional (unless the button is really small and is hard to click on spot)

daisyUI provides some built-in themes with opinionated colors, animations, etc it's easy to customize them or even create a new theme.
For example you can set "--btn-focus-scale": "1", to disable the shrinking animation. Or you can even do "--btn-focus-scale": "1.05", to make the buttons grow on click instead of shrink.

@tkgregory
Copy link
Author

Thanks for the added details. I agree it's uncommon to click on the edge of the button, but I did it a few times so it's not impossible.

So daisyUI is just CSS. The drawer component is interactive so I thought of wrapping the button in an element that doesn't shrink (to handle the click event). If daisyUI is CSS only, I guess this is not possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants