Skip to content

Commit

Permalink
Merge pull request #1555 from clauderic/keyboard-end-on-tab
Browse files Browse the repository at this point in the history
End keyboard drag operation when pressing tab
  • Loading branch information
clauderic authored Dec 5, 2024
2 parents 2d86292 + 62f632a commit 14bd7d0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
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

0 comments on commit 14bd7d0

Please sign in to comment.