From 0ee7f3b336b02796f7c82de5e4ccd040b356b8b6 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Wed, 10 Nov 2021 15:19:37 +1100 Subject: [PATCH] Fix Navigation accessibility issues (#36292) * Fix display contents accessibility issue in Navigation * Remove aria-hidden from navigation wrapper. * Fix content justification in overlay nav. * Fix for alignment inside overlay menu. * Move text align rule. * Revert "Fix content justification in overlay nav." This reverts commit 5170bb5bb3b9ead314a1ecec68768f2fe2511804. * Fix php lint errors. Co-authored-by: jasmussen --- lib/block-supports/layout.php | 18 ++++++++-- packages/block-editor/src/layouts/flex.js | 32 ++++++++++++++---- .../src/navigation-submenu/style.scss | 4 +++ .../block-library/src/navigation/block.json | 3 +- .../src/navigation/edit/responsive-wrapper.js | 6 +--- .../block-library/src/navigation/index.php | 2 +- .../block-library/src/navigation/style.scss | 33 ++++++++++--------- .../block-library/src/page-list/style.scss | 7 ++-- 8 files changed, 70 insertions(+), 35 deletions(-) diff --git a/lib/block-supports/layout.php b/lib/block-supports/layout.php index 3ba5aca6a35c6d..dee0e654c43c65 100644 --- a/lib/block-supports/layout.php +++ b/lib/block-supports/layout.php @@ -103,14 +103,26 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support */ if ( ! empty( $layout['justifyContent'] ) && array_key_exists( $layout['justifyContent'], $justify_content_options ) ) { $style .= "justify-content: {$justify_content_options[ $layout['justifyContent'] ]};"; - // --justification-setting allows children to inherit the value regardless or row or column direction. - $style .= "--justification-setting: {$justify_content_options[ $layout['justifyContent'] ]};"; + if ( ! empty( $layout['setCascadingProperties'] ) && $layout['setCascadingProperties'] ) { + // --layout-justification-setting allows children to inherit the value regardless or row or column direction. + $style .= "--layout-justification-setting: {$justify_content_options[ $layout['justifyContent'] ]};"; + $style .= '--layout-direction: row;'; + $style .= "--layout-wrap: $flex_wrap;"; + $style .= "--layout-justify: {$justify_content_options[ $layout['justifyContent'] ]};"; + $style .= '--layout-align: center;'; + } } } else { $style .= 'flex-direction: column;'; if ( ! empty( $layout['justifyContent'] ) && array_key_exists( $layout['justifyContent'], $justify_content_options ) ) { $style .= "align-items: {$justify_content_options[ $layout['justifyContent'] ]};"; - $style .= "--justification-setting: {$justify_content_options[ $layout['justifyContent'] ]};"; + if ( ! empty( $layout['setCascadingProperties'] ) && $layout['setCascadingProperties'] ) { + // --layout-justification-setting allows children to inherit the value regardless or row or column direction. + $style .= "--layout-justification-setting: {$justify_content_options[ $layout['justifyContent'] ]};"; + $style .= '--layout-direction: column;'; + $style .= '--layout-justify: initial;'; + $style .= "--layout-align: {$justify_content_options[ $layout['justifyContent'] ]};"; + } } } $style .= '}'; diff --git a/packages/block-editor/src/layouts/flex.js b/packages/block-editor/src/layouts/flex.js index c929a67440b7a2..968e7694db634d 100644 --- a/packages/block-editor/src/layouts/flex.js +++ b/packages/block-editor/src/layouts/flex.js @@ -85,7 +85,10 @@ export default { ); }, save: function FlexLayoutStyle( { selector, layout } ) { - const { orientation = 'horizontal' } = layout; + const { + orientation = 'horizontal', + setCascadingProperties = false, + } = layout; const blockGapSupport = useSetting( 'spacing.blockGap' ); const hasBlockGapStylesSupport = blockGapSupport !== null; const justifyContent = @@ -94,21 +97,36 @@ export default { const flexWrap = flexWrapOptions.includes( layout.flexWrap ) ? layout.flexWrap : 'wrap'; - // --justification-setting allows children to inherit the value - // regardless or row or column direction. - const rowOrientation = ` + let rowOrientation = ` flex-direction: row; align-items: center; justify-content: ${ justifyContent }; - --justification-setting: ${ justifyContent }; `; + if ( setCascadingProperties ) { + // --layout-justification-setting allows children to inherit the value + // regardless or row or column direction. + rowOrientation += ` + --layout-justification-setting: ${ justifyContent }; + --layout-direction: row; + --layout-wrap: ${ flexWrap }; + --layout-justify: ${ justifyContent }; + --layout-align: center; + `; + } const alignItems = alignItemsMap[ layout.justifyContent ] || alignItemsMap.left; - const columnOrientation = ` + let columnOrientation = ` flex-direction: column; align-items: ${ alignItems }; - --justification-setting: ${ alignItems }; `; + if ( setCascadingProperties ) { + columnOrientation += ` + --layout-justification-setting: ${ alignItems }; + --layout-direction: column; + --layout-justify: initial; + --layout-align: ${ alignItems }; + `; + } return (