diff --git a/packages/components/src/hooks/use-keyboard-nav.ts b/packages/components/src/hooks/use-keyboard-nav.ts index e7774fe9..96f50699 100644 --- a/packages/components/src/hooks/use-keyboard-nav.ts +++ b/packages/components/src/hooks/use-keyboard-nav.ts @@ -118,7 +118,7 @@ export const getHandleKeyboardNav = ( break; case KeyCodes.Space: case KeyCodes.Enter: - setSelectedIds({ mainSelection: focusedId, ids: [focusedId] }); + setSelectedIds({ lastSelectedId: focusedId, ids: [focusedId] }); break; default: } diff --git a/packages/components/src/hooks/use-tree-view-keyboard-interaction.ts b/packages/components/src/hooks/use-tree-view-keyboard-interaction.ts index 754a25d0..d8849140 100644 --- a/packages/components/src/hooks/use-tree-view-keyboard-interaction.ts +++ b/packages/components/src/hooks/use-tree-view-keyboard-interaction.ts @@ -63,7 +63,7 @@ export const useTreeViewKeyboardInteraction = ({ if (!itemId) return; if (selectionFollowsFocus) { - select({ mainSelection: itemId, ids: [itemId] }, 'keyboard'); + select({ lastSelectedId: itemId, ids: [itemId] }, 'keyboard'); } else { focus(itemId); } @@ -75,7 +75,7 @@ export const useTreeViewKeyboardInteraction = ({ if (!focusedItemId) { return; } - select({ mainSelection: focusedItemId, ids: [focusedItemId] }); + select({ lastSelectedId: focusedItemId, ids: [focusedItemId] }); }, [focusedItemId, select]); const handleArrowRight = useCallback(() => { @@ -112,9 +112,12 @@ export const useTreeViewKeyboardInteraction = ({ if (event.shiftKey) { if (!selectedIds.includes(previous)) { - select({ mainSelection: previous, ids: [...selectedIds, previous] }); + select({ lastSelectedId: previous, ids: [...selectedIds, previous] }); } else { - select({ mainSelection: focusedItemId, ids: selectedIds.filter((id) => id !== focusedItemId) }); + select({ + lastSelectedId: focusedItemId, + ids: selectedIds.filter((id) => id !== focusedItemId), + }); } } } @@ -131,9 +134,12 @@ export const useTreeViewKeyboardInteraction = ({ if (event.shiftKey) { if (!selectedIds.includes(next)) { - select({ mainSelection: next, ids: [...selectedIds, next] }); + select({ lastSelectedId: next, ids: [...selectedIds, next] }); } else { - select({ mainSelection: focusedItemId, ids: selectedIds.filter((id) => id !== focusedItemId) }); + select({ + lastSelectedId: focusedItemId, + ids: selectedIds.filter((id) => id !== focusedItemId), + }); } } } diff --git a/packages/components/src/list/list.tsx b/packages/components/src/list/list.tsx index 506224ce..57a9deef 100644 --- a/packages/components/src/list/list.tsx +++ b/packages/components/src/list/list.tsx @@ -157,7 +157,7 @@ export function List({ return; } - setSelectedIds({ mainSelection: id, ids: [id] }); + setSelectedIds({ lastSelectedId: id, ids: [id] }); return; } @@ -166,14 +166,14 @@ export function List({ if (isCtrlPressed && isAlreadySelected) { setSelectedIds({ - mainSelection: id, + lastSelectedId: id, ids: selectedIds.ids.filter((selectedId) => selectedId !== id), }); } else if (isCtrlPressed) { - setSelectedIds({ mainSelection: id, ids: [...selectedIds.ids, id] }); + setSelectedIds({ lastSelectedId: id, ids: [...selectedIds.ids, id] }); } else if (isShiftPressed) { setSelectedIds({ - mainSelection: id, + lastSelectedId: id, ids: getRangeSelection({ items, id, @@ -184,7 +184,7 @@ export function List({ }), }); } else { - setSelectedIds({ mainSelection: id, ids: [id] }); + setSelectedIds({ lastSelectedId: id, ids: [id] }); } }, [setFocusedId, selectedIds, enableMultiselect, setSelectedIds, items, indexMap, getId], diff --git a/packages/components/src/list/types.ts b/packages/components/src/list/types.ts index fc73c7b0..a502208e 100644 --- a/packages/components/src/list/types.ts +++ b/packages/components/src/list/types.ts @@ -1,4 +1,4 @@ export interface ListSelection { - mainSelection?: string; + lastSelectedId?: string; ids: string[]; } diff --git a/packages/components/src/tree/boards/tree-with-lanes.board.tsx b/packages/components/src/tree/boards/tree-with-lanes.board.tsx index 0c599050..7c81654e 100644 --- a/packages/components/src/tree/boards/tree-with-lanes.board.tsx +++ b/packages/components/src/tree/boards/tree-with-lanes.board.tsx @@ -183,7 +183,7 @@ export default createBoard({ getParents, selectItem: (item) => { updateSelection({ - mainSelection: item.id, + lastSelectedId: item.id, ids: [item.id], }); },