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

Keyboard sensor requires events to bubble up to document #1612

Open
richardpilot opened this issue Feb 14, 2025 · 1 comment
Open

Keyboard sensor requires events to bubble up to document #1612

richardpilot opened this issue Feb 14, 2025 · 1 comment

Comments

@richardpilot
Copy link

richardpilot commented Feb 14, 2025

We're using a dndkit within a modal / dialog-like experience. The modal code is from an external component library that we do not control. The modal itself has an onKeyDown listener to prevent keyboard events designed for the modal to bubble up to the main document.

This leads to a problem for dndkit usage as, when using the keyboard, once the drag event has started, the only way for that drag event to end is for the onKeyDown listener attached to the document to be triggered but the modal event listener is preventing that from happening. My belief is that the Modal component is correct in it's behaviour.

I see a few options to address this:

  1. Add/Remove the event listener on the target. This seems to be the most sensible and simple fix, we're in full control of the active node in the sensor and just because the target is being dragged by the keyboard doesn't mean it shouldn't still receive events related to drop.
  2. Adding an option to attach a listener on the parent node of the DndContext. Less reliable as we have no control / awareness of where the element within the user's application.
  3. Adding an option to provide a custom target for the onKeyDown event. Most complex but also allows the user to control exactly where the event is attached.
@richardpilot
Copy link
Author

Related to #1367
Similar to the suggestion in that issue, we'd need to move a number the KeyboardSensor's methods to protected (attach/dettach/handleStart) in order to have a custom implementation of our own.

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

1 participant