Skip to content

Commit

Permalink
ToolsPanelItem: mark resetAllFilter as optional, assign noop de…
Browse files Browse the repository at this point in the history
…fault value
  • Loading branch information
ciampo committed Feb 9, 2023
1 parent ebe5493 commit 378ee00
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ these functions through to the panel's `resetAll` callback. They can then be
iterated over to perform additional tasks.

- Required: No
- Default: `() => {}`
4 changes: 3 additions & 1 deletion packages/components/src/tools-panel/tools-panel-item/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { useContextSystem, WordPressComponentProps } from '../../ui/context';
import { useCx } from '../../utils/hooks/use-cx';
import type { ToolsPanelItemProps } from '../types';

const noop = () => {};

export function useToolsPanelItem(
props: WordPressComponentProps< ToolsPanelItemProps, 'div' >
) {
Expand All @@ -22,7 +24,7 @@ export function useToolsPanelItem(
isShownByDefault,
label,
panelId,
resetAllFilter,
resetAllFilter = noop,
onDeselect,
onSelect,
...otherProps
Expand Down
4 changes: 3 additions & 1 deletion packages/components/src/tools-panel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ export type ToolsPanelItem = {
* A `ToolsPanel` will collect each item's `resetAllFilter` and pass an
* array of these functions through to the panel's `resetAll` callback. They
* can then be iterated over to perform additional tasks.
*
* @default noop
*/
resetAllFilter: ResetAllFilter;
resetAllFilter?: ResetAllFilter;
};

export type ToolsPanelItemProps = ToolsPanelItem & {
Expand Down

0 comments on commit 378ee00

Please sign in to comment.