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

Search as a filter not working properly #956

Open
fabio-carvalho88 opened this issue May 28, 2024 · 1 comment
Open

Search as a filter not working properly #956

fabio-carvalho88 opened this issue May 28, 2024 · 1 comment

Comments

@fabio-carvalho88
Copy link

Problem

When following search as a filter storybook example this happens:

Screen.Recording.2024-05-28.at.19.32.49.mov

Does anyone know how to fix it or a workaround to it?

@fabio-carvalho88
Copy link
Author

fabio-carvalho88 commented May 29, 2024

we can't fully follow the storybook example, which relies on logic that happens behind the scenes.

In my case, I've ended up creating a useSearch custom hook which receives the table data as prop.

useSearch hook will allow me to toggle the search and store the current search value (just like in the storybook example). the only extra thing I've added is a filter to the table data:

const filteredData = useMemo(() => {
    return data.filter(({ c }) => c.includes(searchValue));
  }, [data, searchValue]);

This is a simple solution which makes me wonder why the problem recorded in the video above happens.

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

1 participant