JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
14.84k stars 1.08k forks source link

ModalNavigationDrawer gestures easily consume clicks #4748

Open sproctor opened 2 weeks ago

sproctor commented 2 weeks ago

Describe the bug Gestures from ModalNavigationDrawer don't make much sense in a desktop environment, but disabling them also disables closing the drawer by clicking on the scrim.

That said, when gestures are enabled any small movement of the mouse is interpreted as a drag instead of a click. I've read that the friction of the mouse is supposed to prevent this, but I have one user who loses approximately 50% of his clicks to this.

I would really like to see either touch slop or something similar applied to mouse movements, or any Material components that have a gesture feature like this have it ignore mouse events. Actually, having ModalNavigationDrawer ignore mouse gestures would make a lot of sense on Android too.

Affected platforms

Versions

m-sasha commented 2 weeks ago

Can you be more specific? What is happening that is wrong? Please provide a code sample and reproduction instructions.

sproctor commented 2 weeks ago

Typically when you click down on a button, you can move the mouse around on that button and when you release, the onClick handler will be called. When using ModalNavigationDrawer, when you click on a button, if you move the mouse horizontally at all before release, the click will be canceled and interpreted as a drag event by the navigation drawer. I think this is an issue on desktop and Android, but a bigger issue on desktop because it's rare to use a mouse on Android.

https://github.com/sproctor/ComposeDragBug

In this example, you can uncomment the line to disable gestures, which fixes the issue. The problem with that is that then clicking on the scrim doesn't dismiss the drawer.