From 60055e686ea1e8a0a5d302955e01f6d61fee0831 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 4 Oct 2021 15:15:10 +0200 Subject: [PATCH 1/3] Global Styles: add fallback label to `NavigationButton` when navigating to previous screen --- .../components/global-styles/navigation-button.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/edit-site/src/components/global-styles/navigation-button.js b/packages/edit-site/src/components/global-styles/navigation-button.js index c891a79302b4b7..77c3f96317b8f2 100644 --- a/packages/edit-site/src/components/global-styles/navigation-button.js +++ b/packages/edit-site/src/components/global-styles/navigation-button.js @@ -7,18 +7,29 @@ import { FlexItem, __experimentalHStack as HStack, } from '@wordpress/components'; +import { __ } from '@wordpress/i18n'; import { Icon } from '@wordpress/icons'; function NavigationButton( { path, icon, children, + label: labelProp, isBack = false, ...props } ) { const navigator = useNavigator(); + + const defaultLabel = isBack + ? __( 'Navigate to the previous screen' ) + : undefined; + return ( - navigator.push( path, { isBack } ) } { ...props }> + navigator.push( path, { isBack } ) } + aria-label={ labelProp ?? defaultLabel } + { ...props } + > { icon && ( From af9a939e21d652c7c90f8bccee63f3a4aec72cfd Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 4 Oct 2021 16:03:59 +0200 Subject: [PATCH 2/3] Update copy: from "screen" to "view" --- .../edit-site/src/components/global-styles/navigation-button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/edit-site/src/components/global-styles/navigation-button.js b/packages/edit-site/src/components/global-styles/navigation-button.js index 77c3f96317b8f2..3adcbaa992a037 100644 --- a/packages/edit-site/src/components/global-styles/navigation-button.js +++ b/packages/edit-site/src/components/global-styles/navigation-button.js @@ -21,7 +21,7 @@ function NavigationButton( { const navigator = useNavigator(); const defaultLabel = isBack - ? __( 'Navigate to the previous screen' ) + ? __( 'Navigate to the previous view' ) : undefined; return ( From a528e2242acc93cbab0834a09e3ab8b7c5b69b2e Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Tue, 5 Oct 2021 09:05:29 +0200 Subject: [PATCH 3/3] Add the back button s label directly from `ScreenHeader` --- .../src/components/global-styles/header.js | 3 ++- .../components/global-styles/navigation-button.js | 13 +------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/header.js b/packages/edit-site/src/components/global-styles/header.js index 1ddd562aa2ee24..f380aa76330831 100644 --- a/packages/edit-site/src/components/global-styles/header.js +++ b/packages/edit-site/src/components/global-styles/header.js @@ -8,7 +8,7 @@ import { __experimentalHeading as Heading, __experimentalView as View, } from '@wordpress/components'; -import { isRTL } from '@wordpress/i18n'; +import { isRTL, __ } from '@wordpress/i18n'; import { chevronRight, chevronLeft, Icon } from '@wordpress/icons'; /** @@ -31,6 +31,7 @@ function ScreenHeader( { back, title, description } ) { } size="small" isBack + aria-label={ __( 'Navigate to the previous view' ) } /> diff --git a/packages/edit-site/src/components/global-styles/navigation-button.js b/packages/edit-site/src/components/global-styles/navigation-button.js index 3adcbaa992a037..c891a79302b4b7 100644 --- a/packages/edit-site/src/components/global-styles/navigation-button.js +++ b/packages/edit-site/src/components/global-styles/navigation-button.js @@ -7,29 +7,18 @@ import { FlexItem, __experimentalHStack as HStack, } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; import { Icon } from '@wordpress/icons'; function NavigationButton( { path, icon, children, - label: labelProp, isBack = false, ...props } ) { const navigator = useNavigator(); - - const defaultLabel = isBack - ? __( 'Navigate to the previous view' ) - : undefined; - return ( - navigator.push( path, { isBack } ) } - aria-label={ labelProp ?? defaultLabel } - { ...props } - > + navigator.push( path, { isBack } ) } { ...props }> { icon && (