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

Reset query params to the initial params when un-mounting. #3

Conversation

kylorhall
Copy link

@kylorhall kylorhall commented Mar 8, 2022

I encountered the same issue as #1 and ended up fixing it locally in our own decorator–no longer using this addon–but I might as well push it upstream to this addon. Further basis in that issue and this comment. Should fix #1.

When unmounting our Story, this takes the initialSearch (the initial location.search) and set location.search to the original value.

⚠️ This does not maintain any query params added in the meantime, eg. if some other Storybook addon modifies the query parameters, it will be lost as initialSearch.current is from the very first render and never updated.

Quick video to visualize the Storybook file changes:
https://www.loom.com/share/bc19e586965f45a7b9b17b865b7e79ed

When unmounting our Story, we take the `initialSearch` (the initial `location.search`) and set `location.search` to the original value.

This does not maintain any query params added in the meantime, eg. if some other Storybook addon modifies the query parameters.
@kylorhall kylorhall mentioned this pull request Mar 8, 2022
@ndelangen
Copy link
Member

@kylorhall would you like maintainer right to this package?

@kylorhall
Copy link
Author

Hey @ndelangen unfortunately my new role does not use Storybook very much and not this use-case for certain; I wouldn't have any need or ability to maintain this now. I'm happy to direct someone from my prior organization if you were looking, see if they're keen—if they use this workaround I built or not.

@ndelangen
Copy link
Member

Ok, I'll close this PR for now, until there's someone interested in this.

@ndelangen ndelangen closed this Jan 16, 2023
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.

[Bug]
2 participants