-
Notifications
You must be signed in to change notification settings - Fork 139
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
chore(docs): fix page-loaded class #4013
Conversation
@mcoker @wise-king-sullyman FYI pushed one additional change, to wrap this code in |
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.
Manually applied to my local dev server (until docs framework full page examples are fixed) - LGTM!
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.
I remember having some funky behavior when I tried using a useEffect for this in the initial approach, but I also didn't have the readyState check which I'm guessing resolves that issue since if it isn't done doing the initial paint when the effect runs it should add the listener, and when it is it should just load the class.
I do wonder if there might be an edge case here if the effect starts running before painting is complete, but not in time for the listener to catch the event, but we can always cross that bridge if/when we get there.
Towards #4009
This PR wraps the window.load listener in a check to see if the page has already completed loading before adding that listener (and if so, adds the page-loaded class).
main
branch.