From c2e83614fcb936513b9470c64c88367d37fbf8a2 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Fri, 17 Jan 2020 16:31:44 +0100 Subject: [PATCH] Accessibility: Show open button when the sidebar is closed and tabbing out of the content --- .../src/components/editor-regions/style.scss | 25 +++++++++-- .../edit-post/src/components/layout/index.js | 36 ++++++++++++--- .../src/components/layout/style.scss | 44 ++++++++++--------- 3 files changed, 75 insertions(+), 30 deletions(-) diff --git a/packages/edit-post/src/components/editor-regions/style.scss b/packages/edit-post/src/components/editor-regions/style.scss index 65eceb6e17f040..671b782901fe59 100644 --- a/packages/edit-post/src/components/editor-regions/style.scss +++ b/packages/edit-post/src/components/editor-regions/style.scss @@ -74,6 +74,27 @@ html { } .edit-post-editor-regions__sidebar { + display: none; + + @include break-medium() { + display: block; + z-index: z-index(".edit-post-editor-regions__sidebar"); + position: fixed !important; // Need to override the default relative positionning + top: -9999em; + bottom: auto; + left: auto; + right: 0; + width: $sidebar-width; + + &:focus { + top: auto; + bottom: 0; + } + } +} + +.is-sidebar-opened .edit-post-editor-regions__sidebar { + display: block; width: auto; // Keep the sidebar width flexible. flex-shrink: 0; position: absolute; @@ -84,10 +105,6 @@ html { left: 0; background: $white; - &:empty { - display: none; - } - // On Mobile the header is fixed to keep HTML as scrollable. @include break-medium() { overflow: auto; diff --git a/packages/edit-post/src/components/layout/index.js b/packages/edit-post/src/components/layout/index.js index adefc6eb48d83d..f09141b9a89055 100644 --- a/packages/edit-post/src/components/layout/index.js +++ b/packages/edit-post/src/components/layout/index.js @@ -52,9 +52,11 @@ import WelcomeGuide from '../welcome-guide'; function Layout() { const isMobileViewport = useViewportMatch( 'small', '<' ); - const { closePublishSidebar, togglePublishSidebar } = useDispatch( - 'core/edit-post' - ); + const { + closePublishSidebar, + openGeneralSidebar, + togglePublishSidebar, + } = useDispatch( 'core/edit-post' ); const { mode, isRichEditingEnabled, @@ -66,6 +68,7 @@ function Layout() { hasFixedToolbar, previousShortcut, nextShortcut, + hasBlockSelected, } = useSelect( ( select ) => { return { hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( @@ -93,6 +96,9 @@ function Layout() { nextShortcut: select( 'core/keyboard-shortcuts' ).getAllShortcutRawKeyCombinations( 'core/edit-post/next-region' ), + hasBlockSelected: select( + 'core/block-editor' + ).getBlockSelectionStart(), }; }, [] ); const showPageTemplatePicker = __experimentalUsePageTemplatePickerVisible(); @@ -103,6 +109,10 @@ function Layout() { 'has-fixed-toolbar': hasFixedToolbar, 'has-metaboxes': hasActiveMetaboxes, } ); + const openSidebarPanel = () => + openGeneralSidebar( + hasBlockSelected ? 'edit-post/block' : 'edit-post/document' + ); return ( <> @@ -120,6 +130,22 @@ function Layout() { sidebar={ ! publishSidebarOpened && ( <> + { ! sidebarIsOpened && ( +
+ +
+ ) } @@ -165,10 +191,10 @@ function Layout() { } /> ) : ( -
+