Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MRT_FilterTextField.tsx #1260

Open
wants to merge 3 commits into
base: v2
Choose a base branch
from

Conversation

NarenderDhamarlapally
Copy link

@NarenderDhamarlapally NarenderDhamarlapally commented Oct 7, 2024

https://github.com/user-attachments/assets/2c26f71d-1b8c-48e1-b0d5-6bc13749c9e6
empty string as a number,

type = "number"
muiFilterTextFieldProps: ({ column }) => {
return {
type: column?.columnDef?.meta?.type, // number
}

Warning: Received NaN for the value attribute. If this is expected, cast the value to a string.

when manualfilter is true

Plese check the codesandbox

empty string as a number
Copy link

vercel bot commented Oct 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
material-react-table ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 8, 2024 5:46am
material-react-table-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 8, 2024 5:46am

if we convert to string to valueAsNumber then 
column.setfiltervalue is not taking direct 0 value
@NarenderDhamarlapally
Copy link
Author

This pull request includes a small but important change to the MRT_FilterTextField component in the packages/material-react-table package. The change ensures that the value is properly handled when the input type is number.

@@ -179,7 +179,7 @@ export const MRT_FilterTextField = <TData extends MRT_RowData>({
textFieldProps.type === 'date'
? event.target.valueAsDate
: textFieldProps.type === 'number'
? event.target.valueAsNumber
? isNaN(event.target.valueAsNumber) ? undefined : event.target.value
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this still return event.target.valueAsNumber when valid instead of just value?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The columnFilters are not functioning as expected when the value is a numeric 0,
while they work correctly when the value is the text '0'.

please check the CSB and Video

Copy link
Author

@NarenderDhamarlapally NarenderDhamarlapally Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am working in ERP application user will check > 0 , >=0, <0,<=0.

Zero is not working when number input it is working as text input.

I want to work with number input.

please check Once

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants