ColumnFilterElementTemplateOptions.filterModel type mismatch: declared as ColumnFilterModelOptions but runtime passes ColumnFilterMetaData
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- react, typescript
- Domain
- frontend
Research direction
Compare the ColumnFilterElementTemplateOptions declaration with the runtime usage in ColumnFilter.js, especially the filterModel passed to filterElement around lines 50, 432, and 512. Verify the provided TypeScript reproducer and update the declaration so it matches the runtime metadata object; done means the matchMode access no longer produces a type error.
Written by the indexing model from the issue text.
Description
Describe the bug
When using custom filterElement in DataTable column, runtime argument passed to rendering function is not of type declared in ColumnFilterElementTemplateOptions.filterModel but actually ColumnFilterMetaData | ColumnFilterMetaDataWithConstraint, example:
The TypeScript definition for ColumnFilterElementTemplateOptions.filterModel incorrectly declares it as ColumnFilterModelOptions (a dictionary type), but the runtime implementation in ColumnFilter.js actually passes a single ColumnFilterMetaData object.
This forces developers to either:
- Use any type to bypass TypeScript errors
- Apply incorrect type casts
- Lose type safety when implementing custom filter elements
In ColumnFilter.js:
Line 50 - Extracts single field's metadata:
const filterModel = props.filters[field];
Line 512 - Passes single metadata object to user's filterElement:
ObjectUtils.getJSXElement(getColumnProp('filterElement'), { field, index, filterModel: model, // 'model' is ColumnFilterMetaData, not ColumnFilterModelOptions value, filterApplyCallback, filterCallback })
Line 432 - Returns array of individual ColumnFilterMetaData objects:
const fieldConstraints = () => { return filterModel ? filterModel.constraints || [filterModel] : []; };
Line 91 - Uses .matchMode directly:
const isRowMatchModeSelected = (matchMode) => { return filterModel && filterModel.matchMode === matchMode; };
Language
TypeScript 5.x
Build / Runtime
[ ] Angular
[ ] Vue
[x] React
[ ] Other
Browser(s)
All (this is a TypeScript definition issue)
Reproducer
No response
System Information
Binaries:
Node: 20.11.0
Yarn: 1.22.19
npm: 10.2.4
Browsers:
Edge: Chromium (140.0.3485.81)
Internet Explorer: 11.0.26100.1882
npmPackages:
primereact: ^10.9.2 => 10.9.2
react: ^18.3.1 => 18.3.1
Steps to reproduce the behavior
import { Column } from 'primereact/column';
import { DataTable } from 'primereact/datatable';
import { ColumnFilterElementTemplateOptions } from 'primereact/column';
import { InputText } from 'primereact/inputtext';
import { FilterMatchMode} from "primereact/api";
<Column
field="name"
filter
filterElement={(options: ColumnFilterElementTemplateOptions) => {
// TypeScript error: Property 'matchMode' does not exist on type 'ColumnFilterModelOptions'
const isCustomMode = options.filterModel.matchMode === FilterMatchMode.CUSTOM;
// To access matchMode, developers must do:
// const filterData = options.filterModel[options.field] as ColumnFilterMetaData;
// filterModel is already the single field's metadata
return <InputText value={options.value} />;
}}
/>
Expected behavior
interface ColumnFilterElementTemplateOptions {
field: string;
index: number;
filterModel: ColumnFilterMetaData; // Correct type ?
value: any;
filterApplyCallback(value?: any, index?: number): void;
filterCallback(value?: any, index?: number): void;
}
- Dominant language
- CSS
- Stars
- 8.3k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from primefaces/primereact
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
primefaces/primereact#8552 ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
primefaces/primereact#8550 ·
-
Row checkbox selection tick is invisible in Landing Page Theme sectionPossibly taken @Prakash1185 claimed this 173 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
primefaces/primereact#8545 ·
-
Dependency conflict between jspdf v4 and jspdf-autotable during npm installPossibly taken @Kamran92 claimed this 187 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
primefaces/primereact#8537 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
primefaces/primereact#8551 ·
All issues in primefaces/primereact
Similar issues
-
[BUG]: Shared links drop the configured basePath on GitHub PagesPossibly taken @anshulchikhale30-p claimed this today. Openbug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
StabilityNexus/IdentityTokens-EVM-Frontend#182 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 Under an hour Newbie friendliness 82/100
Leonxlnx/taste-skill#216 ·
Maintainers usually reply within 1 day
-
area: ui Bug Payload OSS
Difficulty 1/5 Under an hour Newbie friendliness 88/100
payloadcms/payload#19839 ·
Maintainers usually reply within 1 day
-
BoxShadow.lerp returns the wrong blur style at t = 0 or t = 1Possibly taken @ArtemChikolaev claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day