Skip to content

Commit

Permalink
Merge in trunk, resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
kienstra committed Apr 15, 2023
2 parents 07d18ee + 9fd9dad commit eb8b909
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ function ListViewBlockSelectButton(
onDragStart,
onDragEnd,
draggable,
isExpanded,
ariaLabel,
ariaDescribedBy,
},
ref
) {
Expand Down Expand Up @@ -76,7 +79,9 @@ function ListViewBlockSelectButton(
onDragEnd={ onDragEnd }
draggable={ draggable }
href={ `#block-${ clientId }` }
aria-hidden={ true }
aria-label={ ariaLabel }
aria-describedby={ ariaDescribedBy }
aria-expanded={ isExpanded }
>
<ListViewExpander onClick={ onToggleExpanded } />
<BlockIcon icon={ blockInformation?.icon } showColors />
Expand Down
43 changes: 15 additions & 28 deletions packages/block-editor/src/components/list-view/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ function ListViewBlock( {
path,
isExpanded,
selectedClientIds,
preventAnnouncement,
isSyncedBranch,
} ) {
const cellRef = useRef( null );
Expand Down Expand Up @@ -90,6 +89,7 @@ function ListViewBlock( {
const { toggleBlockHighlight } = useDispatch( blockEditorStore );

const blockInformation = useBlockDisplayInformation( clientId );
const blockTitle = blockInformation?.title || __( 'Untitled' );
const blockName = useSelect(
( select ) => select( blockEditorStore ).getBlockName( clientId ),
[ clientId ]
Expand All @@ -111,28 +111,19 @@ function ListViewBlock( {
level
);

let blockAriaLabel = __( 'Link' );
if ( blockInformation ) {
blockAriaLabel = isLocked
? sprintf(
// translators: %s: The title of the block. This string indicates a link to select the locked block.
__( '%s link (locked)' ),
blockInformation.title
)
: sprintf(
// translators: %s: The title of the block. This string indicates a link to select the block.
__( '%s link' ),
blockInformation.title
);
}

const settingsAriaLabel = blockInformation
const blockAriaLabel = isLocked
? sprintf(
// translators: %s: The title of the block.
__( 'Options for %s block' ),
blockInformation.title
// translators: %s: The title of the block. This string indicates a link to select the locked block.
__( '%s (locked)' ),
blockTitle
)
: __( 'Options' );
: blockTitle;

const settingsAriaLabel = sprintf(
// translators: %s: The title of the block.
__( 'Options for %s' ),
blockTitle
);

const { isTreeGridMounted, expand, collapse, BlockSettingsMenu } =
useListViewContext();
Expand Down Expand Up @@ -249,18 +240,13 @@ function ListViewBlock( {
id={ `list-view-block-${ clientId }` }
data-block={ clientId }
data-expanded={ canExpand ? isExpanded : undefined }
isExpanded={ canExpand ? isExpanded : undefined }
aria-selected={ !! isSelected || forceSelectionContentLock }
ref={ rowRef }
>
<TreeGridCell
className="block-editor-list-view-block__contents-cell"
colSpan={ colSpan }
ref={ cellRef }
aria-label={ blockAriaLabel }
aria-selected={ !! isSelected || forceSelectionContentLock }
aria-expanded={ canExpand ? isExpanded : undefined }
aria-describedby={ descriptionId }
>
{ ( { ref, tabIndex, onFocus } ) => (
<div className="block-editor-list-view-block__contents-container">
Expand All @@ -277,9 +263,10 @@ function ListViewBlock( {
currentlyEditingBlockInCanvas ? 0 : tabIndex
}
onFocus={ onFocus }
isExpanded={ isExpanded }
isExpanded={ canExpand ? isExpanded : undefined }
selectedClientIds={ selectedClientIds }
preventAnnouncement={ preventAnnouncement }
ariaLabel={ blockAriaLabel }
ariaDescribedBy={ descriptionId }
/>
<div
className="block-editor-list-view-block-select-button__description"
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/components/list-view/leaf.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const ListViewLeaf = forwardRef(
level={ level }
positionInSet={ position }
setSize={ rowCount }
isExpanded={ undefined }
{ ...props }
>
{ children }
Expand Down
18 changes: 15 additions & 3 deletions packages/block-editor/src/components/list-view/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
// Use position relative for row animation.
position: relative;

.components-button {
// When a row is expanded, retain the dark color.
&[aria-expanded="true"] {
color: $gray-900;
}

// Ensure that on hover, the admin color is still used.
&:hover {
color: var(--wp-admin-theme-color);
}
}

// The background has to be applied to the td, not tr, or border-radius won't work.
&.is-selected td {
background: var(--wp-admin-theme-color);
Expand Down Expand Up @@ -93,7 +105,7 @@
&.is-branch-selected.is-first-selected td:last-child {
border-top-right-radius: $radius-block-ui;
}
&[aria-expanded="false"] {
&[data-expanded="false"] {
&.is-branch-selected.is-first-selected td:first-child {
border-top-left-radius: $radius-block-ui;
}
Expand Down Expand Up @@ -380,15 +392,15 @@ $block-navigation-max-indent: 8;
}

// Point downwards when open.
.block-editor-list-view-leaf[aria-expanded="true"] .block-editor-list-view__expander svg {
.block-editor-list-view-leaf[data-expanded="true"] .block-editor-list-view__expander svg {
visibility: visible;
transition: transform 0.2s ease;
transform: rotate(90deg);
@include reduce-motion("transition");
}

// Point rightwards when closed
.block-editor-list-view-leaf[aria-expanded="false"] .block-editor-list-view__expander svg {
.block-editor-list-view-leaf[data-expanded="false"] .block-editor-list-view__expander svg {
visibility: visible;
transform: rotate(0deg);
transition: transform 0.2s ease;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default function useBlockSelection() {
}

if ( label ) {
speak( label );
speak( label, 'assertive' );
}
},
[
Expand Down
5 changes: 5 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- `NavigableContainer`: Convert to TypeScript ([#49377](https://github.com/WordPress/gutenberg/pull/49377)).

### Enhancements

- `TreeGrid`: Modify keyboard navigation code to use a data-expanded attribute if aria-expanded is to be controlled outside of the TreeGrid component ([#48461](https://github.com/WordPress/gutenberg/pull/48461)).

### Documentation

- `Autocomplete`: Add heading and fix type for `onReplace` in README. ([#49798](https://github.com/WordPress/gutenberg/pull/49798)).
Expand All @@ -20,6 +24,7 @@

- `DropZone`: Smooth animation ([#49517](https://github.com/WordPress/gutenberg/pull/49517)).
- `Navigator`: Add `skipFocus` property in `NavigateOptions`. ([#49350](https://github.com/WordPress/gutenberg/pull/49350)).
- `Spinner`: add explicit opacity and background styles ([#49695](https://github.com/WordPress/gutenberg/pull/49695)).

### Bug Fix

Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/spinner/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const StyledSpinner = styled.svg`
position: relative;
color: ${ COLORS.ui.theme };
overflow: visible;
opacity: 1;
background-color: transparent;
`;

const commonPathProps = css`
Expand Down
9 changes: 7 additions & 2 deletions packages/components/src/tree-grid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ function UnforwardedTreeGrid(
const canExpandCollapse = 0 === currentColumnIndex;
const cannotFocusNextColumn =
canExpandCollapse &&
activeRow.getAttribute( 'aria-expanded' ) === 'false' &&
( activeRow.getAttribute( 'data-expanded' ) === 'false' ||
activeRow.getAttribute( 'aria-expanded' ) === 'false' ) &&
keyCode === RIGHT;

if ( ( [ LEFT, RIGHT ] as number[] ).includes( keyCode ) ) {
Expand All @@ -112,6 +113,8 @@ function UnforwardedTreeGrid(
// Left:
// If a row is focused, and it is expanded, collapses the current row.
if (
activeRow.getAttribute( 'data-expanded' ) ===
'true' ||
activeRow.getAttribute( 'aria-expanded' ) === 'true'
) {
onCollapseRow( activeRow );
Expand Down Expand Up @@ -151,8 +154,10 @@ function UnforwardedTreeGrid(
// Right:
// If a row is focused, and it is collapsed, expands the current row.
if (
activeRow.getAttribute( 'data-expanded' ) ===
'false' ||
activeRow.getAttribute( 'aria-expanded' ) ===
'false'
'false'
) {
onExpandRow( activeRow );
event.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@ exports[`PostPublishPanel should render the spinner if the post is being saved 1
position: relative;
color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
overflow: visible;
opacity: 1;
background-color: transparent;
}
.emotion-2 {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/blocks/columns.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test.describe( 'Columns', () => {
// block column add
await page
.locator(
'role=treegrid[name="Block navigation structure"i] >> role=gridcell[name="Column link"i]'
'role=treegrid[name="Block navigation structure"i] >> role=gridcell[name="Column"i]'
)
.first()
.click();
Expand Down
Loading

0 comments on commit eb8b909

Please sign in to comment.