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

Range slider, additional useEffect dependencies #573

Merged
merged 1 commit into from Jun 16, 2023

Conversation

jlundan
Copy link
Contributor

@jlundan jlundan commented Jun 16, 2023

This commit adds min and max values to useEffect dependencies. The change relates to an issue with multiple render cycles, for example while updating table's input data over time before user has a chance to interact with the sliders. If client code updates the table's data set, that triggers another render. If the original data set (on the first render of the component) had zero rows, then filterValues will be set to [0,0] indefinitely (and makes the slider heads appear over each others in zero position) until the user manipulates the sliders in the UI. If the client code pushes in a new data set before the user manipulates the slider in the UI, filterValues will not be updated, since the useEffect does not listen to it, and useState's initial value is set only on the first render. The issue is fixed when user ends a slider drag in the UI, which in turn triggers onChangeCommitted, which calls column.setFilterValue, which sets up the sliders correctly.

This commit adds min and max values to useEffect dependencies. The change relates to an issue with multiple render cycles, for example while updating table's input data over time before user has a chance to interact with the sliders. If client code updates the table's data set, that triggers another render. If the original data set (on the first render of the component) had zero rows, then filterValues will be set to [0,0] indefinitely (and makes the slider heads appear over each others in zero position) until the user manipulates the sliders in the UI. If the client code pushes in a new data set before the user manipulates the slider in the UI, filterValues will not be updated, since the useEffect does not listen to it, and useState's initial value is set only on the first render. The issue is fixed when user ends a slider drag in the UI, which in turn triggers onChangeCommitted, which calls column.setFilterValue, which sets up the sliders correctly.
@vercel
Copy link

vercel bot commented Jun 16, 2023

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 Jun 16, 2023 4:56pm
material-react-table-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 16, 2023 4:56pm

@KevinVandy KevinVandy merged commit 020806f into KevinVandy:main Jun 16, 2023
3 checks passed
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.

None yet

2 participants