From 086f57730d20aad8902daaf9bc5312de7d44e217 Mon Sep 17 00:00:00 2001 From: Mitchell Austin Date: Wed, 17 Apr 2024 12:53:55 -0700 Subject: [PATCH] flag item customization only for default items --- .../src/tools-panel/tools-panel-item/hook.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/components/src/tools-panel/tools-panel-item/hook.ts b/packages/components/src/tools-panel/tools-panel-item/hook.ts index 93f0aec94d8e8f..8d76baf02dfdb8 100644 --- a/packages/components/src/tools-panel/tools-panel-item/hook.ts +++ b/packages/components/src/tools-panel/tools-panel-item/hook.ts @@ -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.