diff --git a/src/TreeView/reducer.ts b/src/TreeView/reducer.ts index 69058a72..27204c0d 100644 --- a/src/TreeView/reducer.ts +++ b/src/TreeView/reducer.ts @@ -215,7 +215,7 @@ export const treeReducer = ( selectedIds, halfSelectedIds, tabbableId: action.keepFocus ? state.tabbableId : action.id, - isFocused: true, + isFocused: action.NotUserAction !== true, lastUserSelect: action.NotUserAction ? state.lastUserSelect : action.id, lastAction: action.type, lastInteractedWith: action.lastInteractedWith, diff --git a/src/__tests__/CheckboxTree.test.tsx b/src/__tests__/CheckboxTree.test.tsx index 63b6bfd1..3f5dd185 100644 --- a/src/__tests__/CheckboxTree.test.tsx +++ b/src/__tests__/CheckboxTree.test.tsx @@ -2,7 +2,7 @@ import "@testing-library/jest-dom/extend-expect"; import { fireEvent, render, screen } from "@testing-library/react"; import React from "react"; import TreeView from "../TreeView"; -import { INode } from "../TreeView/types"; +import { INode, NodeId } from "../TreeView/types"; import { flattenTree } from "../TreeView/utils"; const folder = { @@ -54,7 +54,13 @@ function CheckboxTree({ propagateSelect = true, multiSelect = true, data = initialData, + defaultSelectedIds = [], + defaultExpandedIds = [], + defaultDisabledIds = [], }: { + defaultSelectedIds?: NodeId[]; + defaultExpandedIds?: NodeId[]; + defaultDisabledIds?: NodeId[]; propagateSelect?: boolean; multiSelect?: boolean; data?: INode[]; @@ -67,6 +73,9 @@ function CheckboxTree({ aria-label="Checkbox tree" multiSelect={multiSelect} propagateSelect={propagateSelect} + defaultSelectedIds={defaultSelectedIds} + defaultExpandedIds={defaultExpandedIds} + defaultDisabledIds={defaultDisabledIds} propagateSelectUpwards togglableSelect nodeAction="check" @@ -78,19 +87,18 @@ function CheckboxTree({ isHalfSelected, }) => { return ( -