Skip to content

Global Filter fails to search a column when the top values are null | undefined #444

@EDav1123

Description

@EDav1123

material-react-table version

v.1.9.1

react & react-dom versions

v.18.2.0

Describe the bug and the steps to reproduce it

  1. Create a dataset.
  2. Leave one of the value in the top row as null or undefined.
  3. Create the columns and pass everything to the object. Be sure to not parse the null value as anything but null | undefined
  4. Notice if you try to search for anything under the column where the first value is null or undefined, Golbal Filter won't be able to find anything.

As an additional note, I have tried to make my own custom filter (filterFns) to go around the issue only to find out the entire column was absent from row (the first argument of the filter function).

Minimal, Reproducible Example - (Optional, but Recommended)

https://stackblitz.com/edit/github-5zzklf-3s8ejv?file=src/TS.tsx is the sandbox I've used for the video demo I've provided bellow.

A even more minimalistic exemple would be:

import React, { useMemo } from 'react';
import ReactDOM from 'react-dom/client';
import MaterialReactTable, { type MRT_ColumnDef } from 'material-react-table';

type Fruit = {
  id: number;
  fruit: string | null;
};

const data: string[] = [
  { id: 40, fruit: null },
  { id: 12, fruit: "Poire" },
  { id: 23, fruit: "Oirange" },
];

const Example = () => {
  const columns = useMemo<MRT_ColumnDef<Fruit>[]>(
    () => [ 
      { accessorKey: 'id', header: 'ID' },  
      { accessorKey: 'fruit',  header: 'Fruit' }
    ], [] 
  );

  return <MaterialReactTable columns={columns} data={data} />
}

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
  <React.StrictMode>
    <Example />
  </React.StrictMode>,
);

Screenshots or Videos (Optional)

https://youtu.be/gMFnv27FUug

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

No, because I do not know how

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions