Skip to content

Commit

Permalink
fix(react-keytips): fix tree issue with not removing the nodes (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
mainframev authored Dec 19, 2024
1 parent 6fedbd5 commit d0c919b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: fix the issue with showing duplicates in Overflow",
"packageName": "@fluentui-contrib/react-keytips",
"email": "[email protected]",
"dependentChangeType": "patch"
}
8 changes: 6 additions & 2 deletions packages/react-keytips/src/components/Keytips/useKeytips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,17 @@ export const useKeytips_unstable = (props: KeytipsProps): KeytipsState => {
keytip,
});

if (state.inKeytipMode && tree.isCurrentKeytipParent(keytip)) {
if (tree.isCurrentKeytipParent(keytip)) {
showKeytips(tree.getChildren());
}
};

const handleKeytipRemoved = (keytip: KeytipWithId) => {
tree.removeNode(keytip.uniqueId);
// nodemway mave an alias registered, if it's shortcut
if (keytip.isShortcut) {
tree.removeNode(`${keytip.uniqueId}-alias`);
}

dispatch({ type: ACTIONS.REMOVE_KEYTIP, id: keytip.uniqueId });
};
Expand All @@ -147,7 +151,7 @@ export const useKeytips_unstable = (props: KeytipsProps): KeytipsState => {
return () => {
reset();
};
}, [state.inKeytipMode]);
}, []);

React.useEffect(() => {
const controller = new AbortController();
Expand Down
2 changes: 1 addition & 1 deletion packages/react-keytips/stories/OverflowMenu.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const OverflowMenuItemWrapper = React.forwardRef<
}

return (
<MenuItem id={keytipProps.id} ref={mergedRefs} persistOnClick>
<MenuItem id={keytipProps.id} ref={mergedRefs}>
Item {keytipProps.id}
</MenuItem>
);
Expand Down

0 comments on commit d0c919b

Please sign in to comment.