Skip to content

Commit

Permalink
update to update tabbableId for halfSelect
Browse files Browse the repository at this point in the history
  • Loading branch information
yhy-1 committed Jun 16, 2023
1 parent 72a0bf8 commit 1b5edc7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/TreeView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ const useTree = ({
type: treeTypes.halfSelect,
id,
lastInteractedWith,
keepFocus: true,
NotUserAction: true,
});
}
for (const id of none) {
Expand Down
8 changes: 5 additions & 3 deletions src/TreeView/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export type TreeViewAction =
type: "HALF_SELECT";
id: NodeId;
lastInteractedWith?: NodeId | null;
keepFocus?: boolean;
NotUserAction?: boolean;
}
| {
type: "SELECT";
Expand Down Expand Up @@ -186,8 +188,10 @@ export const treeReducer = (
...state,
selectedIds,
halfSelectedIds,
tabbableId: action.keepFocus ? state.tabbableId : action.id,
lastAction: action.type,
lastInteractedWith: action.lastInteractedWith,
lastUserSelect: action.NotUserAction ? state.lastUserSelect : action.id,
};
}
case treeTypes.select: {
Expand Down Expand Up @@ -233,9 +237,7 @@ export const treeReducer = (
...state,
selectedIds,
halfSelectedIds,
tabbableId: action.keepFocus
? action.lastInteractedWith || state.tabbableId
: action.id,
tabbableId: action.keepFocus ? state.tabbableId : action.id,
isFocused: true,
lastUserSelect: action.NotUserAction ? state.lastUserSelect : action.id,
lastAction: action.type,
Expand Down

0 comments on commit 1b5edc7

Please sign in to comment.