-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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 browser navigation #2261
Fix browser navigation #2261
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2261 +/- ##
==========================================
- Coverage 22.2% 22.16% -0.05%
==========================================
Files 268 268
Lines 5872 5883 +11
Branches 712 709 -3
==========================================
Hits 1304 1304
- Misses 4023 4054 +31
+ Partials 545 525 -20
Continue to review full report at Codecov.
|
const { selectedKind, selectedStory } = clientStore.getAll(); | ||
// use pushState only when a new story is selected | ||
const usePush = | ||
prevKind != null && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there something to push the state for the first story storybook loads when there isn't a previous kind? Or is that not really necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imagine that we opened storybook by a link from other website. If we'll create additional history entries on initialization stage, we won't be able to return to referring website by just hitting "back" button.
That's why we need to replace not push in this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha, makes sense
const { selectedKind, selectedStory } = clientStore.getAll(); | ||
// use pushState only when a new story is selected | ||
const usePush = | ||
prevKind != null && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha, makes sense
Issue: #2134
Currently we spoil browser history with tons of entries, especially when using addon-knobs
What I did
Used
replaceState
most of the times, which doesn't create a new history entry, but replaces the current URL and state object.pushState
is only used when user goes to a new story (each story may be considered a "page")How to test
Open cra-kitchen-sink, navigate to some story with knobs, hit "back" button