diff --git a/docs/data/tree-view/rich-tree-view/headless/headless.md b/docs/data/tree-view/rich-tree-view/headless/headless.md index ece539bc73d5..9b04283c990a 100644 --- a/docs/data/tree-view/rich-tree-view/headless/headless.md +++ b/docs/data/tree-view/rich-tree-view/headless/headless.md @@ -123,7 +123,7 @@ const useCustomPlugin = ({ models }) => { models.expandedItems.setValue([]); // Check if an item is expanded - const isExpanded = instance.isNodeExpanded('some-item-id'); + const isExpanded = useSelector(selectorIsItemExpanded, 'some-item-id'); }; }; ``` diff --git a/packages/x-tree-view/src/hooks/useTreeItemUtils/useTreeItemUtils.tsx b/packages/x-tree-view/src/hooks/useTreeItemUtils/useTreeItemUtils.tsx index 4055d0ff2ea5..623c80a30c05 100644 --- a/packages/x-tree-view/src/hooks/useTreeItemUtils/useTreeItemUtils.tsx +++ b/packages/x-tree-view/src/hooks/useTreeItemUtils/useTreeItemUtils.tsx @@ -185,7 +185,6 @@ export const useTreeItemUtils = < // As a side effect of `instance.focusItem` called here and in `handleCancelItemLabelEditing` the `labelInput` is blurred // The `onBlur` event is triggered, which calls `handleSaveItemLabel` again. // To avoid creating an unwanted behavior we need to check if the item is being edited before calling `updateItemLabel` - // using `instance.isItemBeingEditedRef` instead of `instance.isItemBeingEdited` since the state is not yet updated in this point if (selectorIsItemBeingEdited(store.value, itemId)) { instance.updateItemLabel(itemId, newLabel); toggleItemEditing();