Skip to content

Commit

Permalink
Fix #3655: ENTER key on menu filter input applies filter (#3660)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Nov 16, 2022
1 parent 6898d8f commit 8ec278a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion components/lib/datatable/ColumnFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ export const ColumnFilter = React.memo((props) => {
}
};

const onInputKeydown = (event, _index) => {
if (event.key === 'Enter') {
if (!getColumnProp('showApplyButton') || props.display === 'menu') {
applyFilter();
}
}
};

const onRowMatchModeChange = (matchMode) => {
const filterMatchModeChangeCallback = getColumnProp('onFilterMatchModeChange');
let filters = { ...props.filters };
Expand Down Expand Up @@ -442,7 +450,15 @@ export const ColumnFilter = React.memo((props) => {
return getColumnProp('filterElement') ? (
ObjectUtils.getJSXElement(getColumnProp('filterElement'), { field, index, filterModel: model, value, filterApplyCallback, filterCallback })
) : (
<InputText type={getColumnProp('filterType')} value={value || ''} onChange={(e) => onInputChange(e, index)} className="p-column-filter" placeholder={getColumnProp('filterPlaceholder')} maxLength={getColumnProp('filterMaxLength')} />
<InputText
type={getColumnProp('filterType')}
value={value || ''}
onChange={(e) => onInputChange(e, index)}
onKeyDown={(e) => onInputKeydown(e, index)}
className="p-column-filter"
placeholder={getColumnProp('filterPlaceholder')}
maxLength={getColumnProp('filterMaxLength')}
/>
);
};

Expand Down

0 comments on commit 8ec278a

Please sign in to comment.