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(knobs): cancel debounced onChange on unmounting #3607

Merged
merged 1 commit into from
May 19, 2018

Conversation

kumarharsh
Copy link
Contributor

Issue: The debounced onChange handlers in the knob components are not cancelled when the components are unmounted, which make cause edge cases where if the component is unmounted while the debounced function is still being called, an unhandled error might be thrown.

What I did

Cancelled the debounced function on component unmount

How to test

Too difficult to test reliably, but this is how it'd go:

  1. In the kitchen-sink, use knobs to create some inputs which can be manipulated (text or number would be best)
  2. In the knob/number component, change the debounce duration to be much bigger - say 2000ms (to demonstrate the edge case).
  3. Open the storybook app and change the knob value really fast (press up key, for example)
  4. Select some other component within 2 seconds - the issue should manifest itself.

Is this testable with Jest or Chromatic screenshots? No
Does this need a new example in the kitchen sink apps? No
Does this need an update to the documentation? No

If your answer is yes to any of these, please make sure to include it in your PR.

For maintainers only: Please tag your pull request with at least one of the following:
["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]

@storybook-safe-bot
Copy link
Contributor

Fails
🚫

PR is not labeled with one of: ["cleanup","BREAKING CHANGE","feature request","bug","documentation","maintenance","dependencies:update","dependencies","other"]

Generated by 🚫 dangerJS

@ndelangen ndelangen added the maintenance User-facing maintenance tasks label May 19, 2018
@ndelangen ndelangen merged commit b414338 into storybookjs:master May 19, 2018
@ndelangen
Copy link
Member

Thank you @kumarharsh, congrats on your first PR merged 🎉

@Hypnosphi
Copy link
Member

Released as 4.0.0-alpha.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants