Skip to content

Commit

Permalink
Fix regression with Edit site Navigate regions (#52940)
Browse files Browse the repository at this point in the history
* Make the navigabel region wrap the inert sidebar.

* Adjust animation.
  • Loading branch information
afercia authored and tellthemachines committed Aug 1, 2023
1 parent 6903bb1 commit 1d8bb10
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
47 changes: 27 additions & 20 deletions packages/edit-site/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,28 +260,35 @@ export default function Layout() {
</motion.div>

<div className="edit-site-layout__content">
<motion.div
// The sidebar is needed for routing on mobile
// (https://github.com/WordPress/gutenberg/pull/51558/files#r1231763003),
// so we can't remove the element entirely. Using `inert` will make
// it inaccessible to screen readers and keyboard navigation.
inert={ showSidebar ? undefined : 'inert' }
animate={ { opacity: showSidebar ? 1 : 0 } }
transition={ {
type: 'tween',
duration:
// Disable transition in mobile to emulate a full page transition.
disableMotion || isMobileViewport
? 0
: ANIMATION_DURATION,
ease: 'easeOut',
} }
className="edit-site-layout__sidebar"
{ /*
The NavigableRegion must always be rendered and not use
`inert` otherwise `useNavigateRegions` will fail.
*/ }
<NavigableRegion
ariaLabel={ __( 'Navigation' ) }
className="edit-site-layout__sidebar-region"
>
<NavigableRegion ariaLabel={ __( 'Navigation' ) }>
<motion.div
// The sidebar is needed for routing on mobile
// (https://github.com/WordPress/gutenberg/pull/51558/files#r1231763003),
// so we can't remove the element entirely. Using `inert` will make
// it inaccessible to screen readers and keyboard navigation.
inert={ showSidebar ? undefined : 'inert' }
animate={ { opacity: showSidebar ? 1 : 0 } }
transition={ {
type: 'tween',
duration:
// Disable transition in mobile to emulate a full page transition.
disableMotion || isMobileViewport
? 0
: ANIMATION_DURATION,
ease: 'easeOut',
} }
className="edit-site-layout__sidebar"
>
<Sidebar />
</NavigableRegion>
</motion.div>
</motion.div>
</NavigableRegion>

<SavePanel />

Expand Down
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/layout/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
display: flex;
}

.edit-site-layout__sidebar {
.edit-site-layout__sidebar-region {
z-index: z-index(".edit-site-layout__sidebar");
width: 100vw;
flex-shrink: 0;
Expand All @@ -75,7 +75,7 @@
top: 0;
}

> div {
.edit-site-layout__sidebar {
display: flex;
flex-direction: column;
height: 100%;
Expand Down

0 comments on commit 1d8bb10

Please sign in to comment.