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

fix(slider): Prevent onChange/onChangeAfter called on mount #253

Merged
merged 5 commits into from
Jul 3, 2024

Conversation

vsandvold
Copy link
Contributor

This PR adds guards to the onChange/onChangeAfter useEffect hooks, making sure the callbacks are invoked only when the slider value changes.

@vsandvold
Copy link
Contributor Author

vsandvold commented Jul 2, 2024

This PR replaces and closes #251

// It could be caused by limitations in the testing library
// as mentioned in the docs:
// https://testing-library.com/docs/guide-events#interactions-vs-events
expect(onChange).toHaveBeenCalledTimes(0);
Copy link
Contributor Author

@vsandvold vsandvold Jul 2, 2024

Choose a reason for hiding this comment

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

Manual testing with storybook shows clearly that the onChange callback is called on every update to the slider value, both from clicking and dragging the slider.

@imprashast imprashast merged commit 84ddd64 into warp-ds:next Jul 3, 2024
7 of 8 checks passed
github-actions bot pushed a commit that referenced this pull request Jul 3, 2024
# [1.6.0-next.6](v1.6.0-next.5...v1.6.0-next.6) (2024-07-03)

### Bug Fixes

* **slider:** Prevent onChange/onChangeAfter called on mount ([#253](#253)) ([84ddd64](84ddd64))
github-actions bot pushed a commit that referenced this pull request Jul 3, 2024
# [1.6.0](v1.5.0...v1.6.0) (2024-07-03)

### Bug Fixes

* add default targetEl for callout ([#248](#248)) ([e297880](e297880))
* bump core to fix slider ([#250](#250)) ([5192147](5192147))
* **slider:** Prevent onChange/onChangeAfter called on mount ([#253](#253)) ([84ddd64](84ddd64))

### Features

* add warp ds eslint config ([#238](#238)) ([d83f799](d83f799))
* slider onChangeAfter prop ([#247](#247)) ([fa1af5c](fa1af5c))
* **toggle:** add ReactNode type to toggle labels ([#244](#244)) ([abeff99](abeff99))
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.

3 participants