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

Deactivate keyboard sensor on blur #1087

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jperals
Copy link

@jperals jperals commented Mar 28, 2023

This fixes #857.

As stated in that issue, this cannot be fixed by extending the KeyboardSensor, because all methods are private and this also creates other problems —but adding these changes in the main KeyboardSensor class works as expected. Moreover, I think it makes sense to deactivate dragging on blur as a general case in order to keep the UX consistent with the native browser focus —otherwise this leads to an inconsistent experience where a non-focused element keeps being interactive, which hurts usability and accessibility.

This works for losing focus in any way, therefore both by clicking with the mouse somewhere else or by typing Tab, even though in the latter case the (native) focus will stay on the active draggable element and a new Tab is required to navigate to the next focusable element, because of RestoreFocus. But since that can be overridden by setting restoreFocus to false in the DndContext, I did not include more changes in this PR in order to keep it minimal.

@changeset-bot
Copy link

changeset-bot bot commented Mar 28, 2023

🦋 Changeset detected

Latest commit: d2c2790

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@dnd-kit/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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 this pull request may close these issues.

Cancel drag when the the draggable item loses focus
1 participant