Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #6997: MenuBar re-render on props.model changes #6999

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions components/lib/menubar/Menubar.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ export const Menubar = React.memo(
}
};

const createProcessedItems = React.useCallback((items, level = 0, parent = {}, parentKey = '') => {
const createProcessedItems = (items, level = 0, parent = {}, parentKey = '') => {
const _processedItems = [];

items &&
Expand All @@ -511,7 +511,7 @@ export const Menubar = React.memo(
});

return _processedItems;
}, []);
};

useMountEffect(() => {
if (!idState) {
Expand All @@ -536,7 +536,8 @@ export const Menubar = React.memo(
const processed = createProcessedItems(itemsToProcess, 0, null, '');

setProcessedItems(processed);
}, [props.model, createProcessedItems]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [props.model]);

useUpdateEffect(() => {
const processedItem = activeItemPath.find((p) => p.key === focusedItemInfo.parentKey);
Expand Down
3 changes: 1 addition & 2 deletions components/lib/menubar/MenubarSub.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ export const MenubarSub = React.memo(
const menuitemProps = mergeProps(
{
id,
key: dataId,
'data-id': dataId,
role: 'menuitem',
'aria-label': item.label,
Expand All @@ -259,7 +258,7 @@ export const MenubarSub = React.memo(
);

return (
<li {...menuitemProps}>
<li {...menuitemProps} key={dataId}>
<div {...contentProps}>{content}</div>
{submenu}
</li>
Expand Down
Loading