Skip to content

Commit

Permalink
Fix unit test + add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Dec 5, 2023
1 parent 17a7dcb commit 086accc
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions packages/components/src/tools-panel/tools-panel-item/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ export function useToolsPanelItem(
__experimentalLastVisibleItemClass,
} = useToolsPanelContext();

// hasValue is a new function on every render, so do not add it as a
// dependency to the useCallback hook! If needed, we should use a ref.
// eslint-disable-next-line react-hooks/exhaustive-deps
const hasValueCallback = useCallback( hasValue, [ panelId ] );
// resetAllFilter is a new function on every render, so do not add it as a
// dependency to the useCallback hook! If needed, we should use a ref.
// eslint-disable-next-line react-hooks/exhaustive-deps
const resetAllFilterCallback = useCallback( resetAllFilter, [ panelId ] );
const previousPanelId = usePrevious( currentPanelId );
Expand Down Expand Up @@ -135,17 +139,8 @@ export function useToolsPanelItem(
return;
}

if ( isShownByDefault || currentPanelId === null ) {
flagItemCustomization( label, menuGroup );
}
}, [
currentPanelId,
newValueSet,
isShownByDefault,
menuGroup,
label,
flagItemCustomization,
] );
flagItemCustomization( label, menuGroup );
}, [ newValueSet, menuGroup, label, flagItemCustomization ] );

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

0 comments on commit 086accc

Please sign in to comment.