Skip to content

Commit

Permalink
feat(Datagrid): call onClearFilters when clearing filters from tag su…
Browse files Browse the repository at this point in the history
…mmary (carbon-design-system#5892)

* feat: add onClearFilters to FilterFlyoutProps

* feat: call onClearFilters callback in filter summary

* fix: remove undefined check

* chore: add onClearFilters method docs
  • Loading branch information
xmannyxfreshx1 authored Sep 5, 2024
1 parent 330e902 commit 791618a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,12 @@ export const DatagridContent = ({
<FilterSummary
className={`${blockClass}__filter-summary`}
filters={filterTags}
clearFilters={() => EventEmitter.dispatch(CLEAR_FILTERS, tableId)}
clearFilters={() => {
EventEmitter.dispatch(CLEAR_FILTERS, tableId);
if (typeof filterProps?.onClearFilters === 'function') {
filterProps.onClearFilters();
}
}}
renderLabel={filterProps?.renderLabel}
overflowType="tag"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,27 @@ const datagridState = useDatagrid({
}
});
return <Datagrid datagridState={datagridState} />;
`,
},
},
{
subTitle: `onClearFilters method`,
source: {
language: 'jsx',
code: `
/*
This method is called when the user clears filters from the filters summary.
*/
const datagridState = useDatagrid({
columns,
data,
filterProps: {
onClearFilters: () => console.log('callback to be run after clearing all filters'),
}
});
return <Datagrid datagridState={datagridState} />;
`,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export interface FilterFlyoutProps {
flyoutIconDescription?: string;
onFlyoutClose?: () => void;
onFlyoutOpen?: () => void;
onClearFilters?: () => void;
panelIconDescription?: string;
primaryActionLabel?: string;
reactTableFiltersState?: ReactTableFiltersState[];
Expand Down

0 comments on commit 791618a

Please sign in to comment.