diff --git a/components/lib/datatable/ColumnFilter.js b/components/lib/datatable/ColumnFilter.js index 6a9da8509b..22f336df67 100644 --- a/components/lib/datatable/ColumnFilter.js +++ b/components/lib/datatable/ColumnFilter.js @@ -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 }; @@ -442,7 +450,15 @@ export const ColumnFilter = React.memo((props) => { return getColumnProp('filterElement') ? ( ObjectUtils.getJSXElement(getColumnProp('filterElement'), { field, index, filterModel: model, value, filterApplyCallback, filterCallback }) ) : ( - onInputChange(e, index)} className="p-column-filter" placeholder={getColumnProp('filterPlaceholder')} maxLength={getColumnProp('filterMaxLength')} /> + onInputChange(e, index)} + onKeyDown={(e) => onInputKeydown(e, index)} + className="p-column-filter" + placeholder={getColumnProp('filterPlaceholder')} + maxLength={getColumnProp('filterMaxLength')} + /> ); };