Skip to content

Commit

Permalink
Fix #4994: Filter button still rendered even if show=false (#4996)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Oct 1, 2023
1 parent 106452e commit deec2b2
Showing 1 changed file with 38 additions and 34 deletions.
72 changes: 38 additions & 34 deletions components/lib/datatable/ColumnFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,46 +522,50 @@ export const ColumnFilter = React.memo((props) => {
};

const createMenuButton = () => {
if (showMenuButton()) {
const filterIconProps = mergeProps(
{
'aria-hidden': true
},
getColumnPTOptions('filterIcon')
);
const icon = props.filterIcon || <FilterIcon {...filterIconProps} />;
const columnFilterIcon = IconUtils.getJSXIcon(icon, { ...filterIconProps }, { props });
if (!showMenuButton()) {
return null;
}

const label = filterLabel();
const filterMenuButtonProps = mergeProps(
{
type: 'button',
className: cx('filterMenuButton', { overlayVisibleState, hasFilter }),
'aria-haspopup': true,
'aria-expanded': overlayVisibleState,
onClick: (e) => toggleMenu(e),
onKeyDown: (e) => onToggleButtonKeyDown(e),
'aria-label': label
},
getColumnPTOptions('filterMenuButton', {
context: {
active: hasFilter()
}
})
);
const filterIconProps = mergeProps(
{
'aria-hidden': true
},
getColumnPTOptions('filterIcon')
);
const icon = props.filterIcon || <FilterIcon {...filterIconProps} />;
const columnFilterIcon = IconUtils.getJSXIcon(icon, { ...filterIconProps }, { props });

return (
<button ref={iconRef} {...filterMenuButtonProps}>
{columnFilterIcon}
<Ripple />
</button>
);
}
const label = filterLabel();
const filterMenuButtonProps = mergeProps(
{
type: 'button',
className: cx('filterMenuButton', { overlayVisibleState, hasFilter }),
'aria-haspopup': true,
'aria-expanded': overlayVisibleState,
onClick: (e) => toggleMenu(e),
onKeyDown: (e) => onToggleButtonKeyDown(e),
'aria-label': label
},
getColumnPTOptions('filterMenuButton', {
context: {
active: hasFilter()
}
})
);

return null;
return (
<button ref={iconRef} {...filterMenuButtonProps}>
{columnFilterIcon}
<Ripple />
</button>
);
};

const createClearButton = () => {
if (!showMenuButton()) {
return null;
}

const filterClearIconProps = mergeProps(
{
'aria-hidden': true
Expand Down

0 comments on commit deec2b2

Please sign in to comment.