Fix Wrong Page Underlined as Current Page in Left Nav Bar#1391
Conversation
…er than use global "jumpToState" variable
…yout>, rather than use global "jumpToState" variable
…site Accidentally set "heading" prop for "jumpToState" prop for <BaseLayout> for both in previous commits; fixed that in this commit
…s" subsection of the site
…ection of the site
…ople" section of the site
|
Hi @esu-skoopin thank you for this PR. I tested locally and can confirm the fix works correctly. |
|
@lirenjie95 Would you happen to be able to review this PR? I believe the changes I've made for this PR are very similar to PR #1271 which you reviewed a month ago. |
lirenjie95
left a comment
There was a problem hiding this comment.
This is a cleaner and more robust approach than #1271—eliminating the shared mutable state entirely instead of working around it. I also believe this will resolve #1207, since the cross-locale "Jump to" leakage was caused by the same jumpToState race condition. One more thing, please squash and merge to keep the commit history tidy. Thanks for the great work!
|
Thanks for the fantastic work @JazzJE @RyRy241 @esu-skoopin, and big thanks to the reviewers @Nwakaego-Ego @lirenjie95 ! Merging this one |
Resolves #1304
Perceived Cause Behind Bug
The main issue, as far as we know, is the combination of a build configuration that allows for the site to be built concurrently two pages at a time and the use of the global variable,
jumpToState.This is the relevant build setting:
We can take a simulated look at what's happening to better understand the problem:
jumpToStatejumpToStatefor page AjumpToStatefor page BjumpToStatefor page AjumpToStatefor page BBecause the site is being built concurrently two pages at a time, it's possible for
jumpToStateto be overwritten by page B before page A can read fromjumpToState.This can result in the visual bug, as seen below.
Current page incorrectly underlined as "Map"
Current page correctly underlined as "Map"
*The assumption is that these pages were built concurrently at build time and "Map" overwrote
jumpToStatebefore "Linear Interpolation" could read from itOur Solution
For our solution, we didn't want to simply change the build config for the site, as we believe that this config setting was most likely put in place for a good reason, so we instead decided to replace the use of the global
jumpToStatevariable with a "jumpToState" prop for the <BaseLayout> and <Nav> components.jumpToStatevariable↓
Global
jumpToStatevariable potentially gets overwritten by another page↓
<Nav jumpToState={global
jumpToStatevariable}>↓
<Nav jumpToState={page}>
Screenshots of our solution working as expected locally:
Feedback welcome!