-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Try restoring the site editor animation #51956
Changes from 2 commits
cf0be29
af387c5
9d8f62b
e1274aa
2425841
7fa2fdc
3645aef
828f2da
b91069e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,11 +228,20 @@ export default function Layout() { | |
ariaLabel={ __( 'Editor top bar' ) } | ||
as={ motion.div } | ||
variants={ { | ||
isDistractionFree: { opacity: 0 }, | ||
isDistractionFreeHovering: { opacity: 1 }, | ||
view: { opacity: 1 }, | ||
edit: { opacity: 1 }, | ||
isDistractionFree: { opacity: 0, y: 0 }, | ||
isDistractionFreeHovering: { | ||
opacity: 1, | ||
y: 0, | ||
}, | ||
view: { opacity: 1, y: '-100%' }, | ||
edit: { opacity: 1, y: 0 }, | ||
} } | ||
exit="view" | ||
initial={ | ||
isDistractionFree | ||
? 'isDistractionFree' | ||
: 'view' | ||
} | ||
transition={ { | ||
type: 'tween', | ||
duration: disableMotion ? 0 : 0.2, | ||
|
@@ -247,21 +256,13 @@ export default function Layout() { | |
|
||
<div className="edit-site-layout__content"> | ||
<AnimatePresence initial={ false }> | ||
{ | ||
{ showSidebar && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kevin940726 mentioned to me that the issue with completely unmounting the sidebar is that it contains hooks that sync the routing state, and while it's unmounted those hooks aren't running, so some navigation doesn't work as expected. This is the reason it was changed in #51558. @youknowriad Wondering if you have any suggestions for solving that in a different way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specifically, here's a bug I found while testing on mobile: Kapture.2023-06-27.at.14.54.22.mp4The previous sidebar still exists but hidden if we use the browser's back button to go back from the edit mode. It has a higher There might be a better and more elegant solution for this though! I didn't have time so I settled with the CSS hack 🤦 . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also related is the issue found here that actually existed before that PR and is potentially related to AnimatePresence not unmounting properly. The added complication is we now need the sidebar mounted on mobile for routing reasons. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Can you clarify which hooks we're talking about here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kevin940726 Do you know the which specific code might be causing that issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we move There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC, that hook relies on |
||
<motion.div | ||
layout | ||
initial={ { | ||
opacity: 0, | ||
} } | ||
animate={ | ||
showSidebar | ||
? { opacity: 1, display: 'block' } | ||
: { | ||
opacity: 0, | ||
transitionEnd: { | ||
display: 'none', | ||
}, | ||
} | ||
} | ||
animate={ { opacity: 1 } } | ||
exit={ { | ||
opacity: 0, | ||
} } | ||
|
@@ -282,7 +283,7 @@ export default function Layout() { | |
<Sidebar /> | ||
</NavigableRegion> | ||
</motion.div> | ||
} | ||
) } | ||
</AnimatePresence> | ||
|
||
<SavePanel /> | ||
|
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.
<AnimatePresence />
is only needed when we need to animate removing an element. We're not removing it from the DOM, just hiding it from user interactions, so we don't need to use this anymore.