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

Columns with null value in first item are excluded from global filter #439

Open
1 task done
rhyek opened this issue Nov 10, 2024 · 2 comments
Open
1 task done

Columns with null value in first item are excluded from global filter #439

rhyek opened this issue Nov 10, 2024 · 2 comments

Comments

@rhyek
Copy link

rhyek commented Nov 10, 2024

mantine-react-table version

2.0.0-beta.7

react & react-dom versions

18.3.1

Describe the bug and the steps to reproduce it

When the first item in the data array has a column with a null value, the global filter excludes that column completely during search.

Steps to reproduce:

  • Open the codesandbox
  • Type any city name in the global filter, eg: Hunt
  • No rows are matched even though the fourth row has city === 'Huntington'

Minimal, Reproducible Example - (Optional, but Recommended)

https://codesandbox.io/p/sandbox/unruffled-hellman-j6hk64

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

No, because I do not have time to dig into it

Terms

  • I understand that if my bug cannot be reliably reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
@desytech
Copy link

desytech commented Nov 18, 2024

This issue is realted to TanStack. There would be several workarounds.

  1. return never null or undefined in accessorFn, it has to be always of type string
  2. use column filterFn: 'includesString' to remove nullisch entries
  3. Enable explicitly global filtering for the affected rows: getColumnCanGlobalFilter: (column) => return true
    3.1 Keep in mind if you will to that you have to implement your globalFilterFn by your own to handle nullisch values
        filterFns: {
            customContains: (row, id, filterValue) => {
                return row.getValue<TData>(id)?.includes(filterValue) || false;
            }
        },

TanStack/table#4919

@rhyek
Copy link
Author

rhyek commented Nov 19, 2024

Taking a quick stab at it, the first option worked.

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

No branches or pull requests

2 participants