Skip to content

Commit 04b1eba

Browse files
committed
feat: do not use redundant drop target at bottom of folder (#363)
1 parent 1a2f9a8 commit 04b1eba

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

next-release-notes.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
<!--
2-
### Breaking Changes
3-
4-
### Features
5-
61
### Bug Fixes and Improvements
7-
- Added some documentation on the data structure required by a StaticDataProvider.
2+
- Improved keyboard-controlled drag and drop behavior to not show redundant drop target directly below opened folder item (#363)
83

94
### Other Changes
10-
-->
5+
- Added some documentation on the data structure required by a StaticDataProvider.

packages/core/src/drag/useGetViableDragPositions.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,18 @@ export const useGetViableDragPositions = () => {
8585
treeId,
8686
};
8787

88-
const skipTopPosition =
89-
depth === (linearItems[linearIndex - 1]?.depth ?? -1);
88+
const depthOfItemAbove = linearItems[linearIndex - 1]?.depth ?? -1;
89+
const depthOfItemBelow = linearItems[linearIndex + 1]?.depth ?? -1;
90+
const isWithinFolder = depth === depthOfItemAbove;
91+
const isBelowOpenFolder = depth === depthOfItemBelow - 1;
9092

91-
if (!skipTopPosition && canDropAt(topPosition, draggingItems)) {
93+
if (!isWithinFolder && canDropAt(topPosition, draggingItems)) {
9294
targets.push(topPosition);
9395
}
9496
if (canDropAt(itemPosition, draggingItems)) {
9597
targets.push(itemPosition);
9698
}
97-
if (canDropAt(bottomPosition, draggingItems)) {
99+
if (!isBelowOpenFolder && canDropAt(bottomPosition, draggingItems)) {
98100
targets.push(bottomPosition);
99101
}
100102
}

packages/core/src/hotkeys/defaultKeyboardBindings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const defaultKeyboardBindings: Required<KeyboardBindings> = {
1111
abortSearch: ['escape', 'enter'],
1212
startSearch: [],
1313
selectAll: ['control+a'],
14-
startProgrammaticDnd: ['control+d'],
14+
startProgrammaticDnd: ['control+shift+d'],
1515
completeProgrammaticDnd: ['enter'],
1616
abortProgrammaticDnd: ['escape'],
1717
};

0 commit comments

Comments
 (0)