Skip to content

Commit

Permalink
flag item customization only for default items
Browse files Browse the repository at this point in the history
  • Loading branch information
stokesman committed Apr 17, 2024
1 parent 80f3545 commit 086f577
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/components/src/tools-panel/tools-panel-item/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,17 @@ export function useToolsPanelItem(
const isRegistered = menuItems?.[ menuGroup ]?.[ label ] !== undefined;

const isValueSet = hasValue();
// Notify the panel when an item's value has changed.
useEffect(
() => flagItemCustomization( isValueSet, label, menuGroup ),
[ isValueSet, menuGroup, label, flagItemCustomization ]
);
// Notify the panel when a default item's value has changed.
useEffect( () => {
if ( isShownByDefault )
flagItemCustomization( isValueSet, label, menuGroup );
}, [
isValueSet,
menuGroup,
label,
flagItemCustomization,
isShownByDefault,
] );

// Determine if the panel item's corresponding menu is being toggled and
// trigger appropriate callback if it is.
Expand Down

0 comments on commit 086f577

Please sign in to comment.