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

Cancel current drag when drawer is closing #262

Closed
henriqemalheiros opened this issue Feb 6, 2024 · 0 comments · Fixed by #263
Closed

Cancel current drag when drawer is closing #262

henriqemalheiros opened this issue Feb 6, 2024 · 0 comments · Fixed by #263

Comments

@henriqemalheiros
Copy link
Contributor

Hey, @emilkowalski! Great work here.

I have a very particular use case: I need to have draggable elements inside the drawer. When an element starts being dragged, the drawer should close to reveal the drop area behind it. The problem is that the drag starts with a onPointerDown event and the onPointerUp event only happens after the drawer has already closed. This causes two problems:

  1. If the user triggers a onPointerDown and immediately starts moving the pointer, the closing animation and the onDrag callback happen at the same time and causes a weird flickering;
  2. Since onPointerUp is never triggered inside the drawer, the onRelease callback is never called and isDragging remains true. When I open the drawer a second time, onDrag will be called without I ever triggering the onPress callback.

We don't need to actually put draggable elements inside the drawer to see it. A button that closes the drawer with onPointerDown is enough. Here's a reproduction: https://codesandbox.io/p/devbox/drawer-without-scale-forked-99shrn

There is also a recording of the problem:

vaul-issue.mp4
@henriqemalheiros henriqemalheiros changed the title Cancel current drag when drawer is closed Cancel current drag when drawer is closing Feb 6, 2024
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

Successfully merging a pull request may close this issue.

1 participant