-
Notifications
You must be signed in to change notification settings - Fork 2
Fix diff sidebar flash on page load #631
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
base: develop
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR addresses visual flash issues during initial page load by implementing client-side hydration guards for the diff sidebar components. The changes ensure that sidebar components and buttons only render after the client-side JavaScript has loaded, preventing mismatches between server-rendered and client-rendered states.
Key Changes:
- Added mounted state checks to
RightContainerandToggleDiffButtonto delay rendering until after hydration - Implemented transition disabling on initial render in
SecondaryContainerto prevent layout shifts - Ensured smooth user experience by conditionally applying CSS transitions only after the first paint
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/features/sidebar/view/internal/tertiary/RightContainer.tsx |
Adds mounted state check to prevent drawer from rendering during SSR |
src/features/sidebar/view/internal/secondary/Container.tsx |
Implements enableTransitions state to disable margin transitions on initial render and prevent layout shift |
src/features/sidebar/view/SecondarySplitHeader.tsx |
Adds mounted state check to ToggleDiffButton to prevent button flash during hydration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
68272b7 to
2f0746e
Compare
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.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/features/sidebar/view/SecondarySplitHeader.tsx:135
- Inconsistent hydration delay mechanism: This component uses
setTimeout(..., 0)for the mounted state, whileRightContainer.tsxusesrequestAnimationFrame()for the same purpose. For consistency and to follow the same SSR hydration pattern established in this PR, consider usingrequestAnimationFrame()here as well:
useEffect(() => {
requestAnimationFrame(() => {
setMounted(true)
setIsMac(checkIsMac())
})
}, []) useEffect(() => {
// checkIsMac uses window so we delay the check.
const timeout = window.setTimeout(() => {
setMounted(true)
setIsMac(checkIsMac())
}, 0)
return () => window.clearTimeout(timeout)
}, [])
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2f0746e to
61daffe
Compare
Warning
Attempt to fix the brief display of the diff sidebar on initial load. It is not quite there yet - the sidebar still flashes briefly while the main container's content readjusts.
Summary
mountedstate check toRightContainerto delay rendering until client-side hydration completesmountedstate check toToggleDiffButtonto prevent button flashenableTransitionsstate toSecondaryContainerto disable margin transitions on initial renderThe sidebar still persists open state during SPA navigation via session storage.