Skip to content

Commit

Permalink
Fix incorrect aria description in List View (#24533)
Browse files Browse the repository at this point in the history
* Fix incorrect siblingCount value

* Remove outdated comment
  • Loading branch information
talldan authored Aug 13, 2020
1 parent 6604d96 commit 5d38f90
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ import BlockNavigationBlockSelectButton from './block-select-button';

const BlockNavigationBlockContents = forwardRef(
(
{ onClick, block, isSelected, position, siblingCount, level, ...props },
{
onClick,
block,
isSelected,
position,
siblingBlockCount,
level,
...props
},
ref
) => {
const {
Expand All @@ -27,7 +35,7 @@ const BlockNavigationBlockContents = forwardRef(
onClick={ onClick }
isSelected={ isSelected }
position={ position }
siblingCount={ siblingCount }
siblingBlockCount={ siblingBlockCount }
level={ level }
{ ...props }
/>
Expand All @@ -39,7 +47,7 @@ const BlockNavigationBlockContents = forwardRef(
onClick={ onClick }
isSelected={ isSelected }
position={ position }
siblingCount={ siblingCount }
siblingBlockCount={ siblingBlockCount }
level={ level }
{ ...props }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function BlockNavigationBlockSelectButton(
isSelected,
onClick,
position,
siblingCount,
siblingBlockCount,
level,
tabIndex,
onFocus,
Expand All @@ -43,7 +43,7 @@ function BlockNavigationBlockSelectButton(
const descriptionId = `block-navigation-block-select-button__${ instanceId }`;
const blockPositionDescription = getBlockPositionDescription(
position,
siblingCount,
siblingBlockCount,
level
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function BlockNavigationBlockSlot( props, ref ) {
block,
isSelected,
position,
siblingCount,
siblingBlockCount,
level,
tabIndex,
onFocus,
Expand All @@ -59,7 +59,7 @@ function BlockNavigationBlockSlot( props, ref ) {
const descriptionId = `block-navigation-block-slot__${ instanceId }`;
const blockPositionDescription = getBlockPositionDescription(
position,
siblingCount,
siblingBlockCount,
level
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default function BlockNavigationBlock( {
position,
level,
rowCount,
siblingBlockCount,
showBlockMovers,
terminatedLevels,
path,
Expand All @@ -49,9 +50,7 @@ export default function BlockNavigationBlock( {
);
const { clientId } = block;

// Subtract 1 from rowCount, as it includes the block appender.
const siblingCount = rowCount - 1;
const hasSiblings = siblingCount > 0;
const hasSiblings = siblingBlockCount > 0;
const hasRenderedMovers = showBlockMovers && hasSiblings;
const hasVisibleMovers = isHovered || isFocused;
const moverCellClassName = classnames(
Expand Down Expand Up @@ -102,7 +101,7 @@ export default function BlockNavigationBlock( {
onClick={ () => onClick( block.clientId ) }
isSelected={ isSelected }
position={ position }
siblingCount={ siblingCount }
siblingBlockCount={ siblingBlockCount }
level={ level }
ref={ ref }
tabIndex={ tabIndex }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ export default function BlockNavigationBranch( props ) {
selectedBlockClientId === parentClientId;
const hasAppender = itemHasAppender( parentBlockClientId );
// Add +1 to the rowCount to take the block appender into account.
const rowCount = hasAppender
? filteredBlocks.length + 1
: filteredBlocks.length;
const blockCount = filteredBlocks.length;
const rowCount = hasAppender ? blockCount + 1 : blockCount;
const appenderPosition = rowCount;

return (
Expand All @@ -64,6 +63,7 @@ export default function BlockNavigationBranch( props ) {
level={ level }
position={ position }
rowCount={ rowCount }
siblingBlockCount={ blockCount }
showBlockMovers={ showBlockMovers }
terminatedLevels={ terminatedLevels }
path={ updatedPath }
Expand Down

0 comments on commit 5d38f90

Please sign in to comment.