Skip to content

Commit

Permalink
bugfix(react-tree): ensure that onActionVisibilityChange is properly …
Browse files Browse the repository at this point in the history
…invoked (#33320)
  • Loading branch information
bsunderhus authored Nov 21, 2024
1 parent 18b80eb commit f7ad10b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "bugfix: ensure that onActionVisibilityChange is properly invoked",
"packageName": "@fluentui/react-tree",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export const useTreeItemLayout_unstable = (
event,
type: event.type,
} as Extract<TreeItemLayoutActionVisibilityChangeData, { event: typeof event }>);
if (event.defaultPrevented) {
return;
}
setIsActionsVisible(true);
}
},
Expand All @@ -97,6 +100,9 @@ export const useTreeItemLayout_unstable = (
event,
type: event.type,
} as Extract<TreeItemLayoutActionVisibilityChangeData, { event: typeof event }>);
if (event.defaultPrevented) {
return;
}
setIsActionsVisible(true);
return;
}
Expand All @@ -108,6 +114,9 @@ export const useTreeItemLayout_unstable = (
event,
type: event.type,
} as Extract<TreeItemLayoutActionVisibilityChangeData, { event: typeof event }>);
if (event.defaultPrevented) {
return;
}
setIsActionsVisible(false);
},
[setIsActionsVisible, onActionVisibilityChange, treeItemRef],
Expand Down Expand Up @@ -155,7 +164,7 @@ export const useTreeItemLayout_unstable = (
const hasActions = Boolean(props.actions);

React.useEffect(() => {
if (treeItemRef.current && hasActions && isActionsVisibleFromProps === undefined) {
if (treeItemRef.current && hasActions) {
const treeItemElement = treeItemRef.current;

const handleMouseOver = setActionsVisibleIfNotFromSubtree;
Expand All @@ -175,13 +184,7 @@ export const useTreeItemLayout_unstable = (
treeItemElement.removeEventListener('blur', handleBlur);
};
}
}, [
hasActions,
treeItemRef,
isActionsVisibleFromProps,
setActionsVisibleIfNotFromSubtree,
setActionsInvisibleIfNotFromSubtree,
]);
}, [hasActions, treeItemRef, setActionsVisibleIfNotFromSubtree, setActionsInvisibleIfNotFromSubtree]);

return {
components: {
Expand Down

0 comments on commit f7ad10b

Please sign in to comment.