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

End keyboard drag operation when pressing tab #1555

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/end-on-tab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@dnd-kit/core': patch
---

Added `Tab` to the list of default key codes that end a drag and drop operation. Can be customized by passing in a custom list of `keyCodes` to the KeyboardSensor options.
2 changes: 1 addition & 1 deletion packages/core/src/sensors/keyboard/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {KeyboardCoordinateGetter, KeyboardCode, KeyboardCodes} from './types';
export const defaultKeyboardCodes: KeyboardCodes = {
start: [KeyboardCode.Space, KeyboardCode.Enter],
cancel: [KeyboardCode.Esc],
end: [KeyboardCode.Space, KeyboardCode.Enter],
end: [KeyboardCode.Space, KeyboardCode.Enter, KeyboardCode.Tab],
};

export const defaultKeyboardCoordinateGetter: KeyboardCoordinateGetter = (
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/sensors/keyboard/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export enum KeyboardCode {
Up = 'ArrowUp',
Esc = 'Escape',
Enter = 'Enter',
Tab = 'Tab',
}

export type KeyboardCodes = {
Expand Down
Loading