emilkowalski / vaul

An unstyled drawer component for React.
https://vaul.emilkowal.ski
MIT License
5.27k stars 170 forks source link

Prevent onPress from setIsDragging(true) if target has [data-vaul-no-drag] attribute #288

Open adambarito opened 4 months ago

adambarito commented 4 months ago

I was experiencing issues with React Aria useDragAndDrop on elements within the drawer.

It appears that the onMouseUp event is not triggering when it happens at the same time as an item is dropped in a dropzone. This means that after dropping an item within the drawer (i.e. releasing the mouse), the drawer doesn't setIsDragging to false and continues to track pointer moves.

My current forked fix is to implement the [data-vaul-no-drag] logic in the onPress function, such that isDragging is never set to true if onPress is triggered by a 'no-drag' element.

Does this sound like a reasonable fix?

https://github.com/emilkowalski/vaul/assets/15056094/7eb89ba1-65f6-4b17-9815-4f7981783e73