Skip to content
Merged
Prev Previous commit
Switch to getting aria-level by attribute instead of adding an extra …
…data attribute
  • Loading branch information
andrewserong committed May 2, 2023
commit 0e90f5d31eb8fafc8a6074e86199c30e3d223bf2
1 change: 0 additions & 1 deletion packages/block-editor/src/components/list-view/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ function ListViewBlock( {
id={ `list-view-${ listViewInstanceId }-block-${ clientId }` }
data-block={ clientId }
data-expanded={ canExpand ? isExpanded : undefined }
data-level={ level }
ref={ rowRef }
>
<TreeGridCell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,12 @@ export default function useListViewDropZone() {
const blocksData = blockElements.map( ( blockElement ) => {
const clientId = blockElement.dataset.block;
const isExpanded = blockElement.dataset.expanded === 'true';
const nestingLevel = blockElement.dataset.level
? parseInt( blockElement.dataset.level, 10 )
: undefined;

// Get nesting level from `aria-level` attribute because Firefox does not support `element.ariaLevel`.
const nestingLevel = parseInt(
blockElement.getAttribute( 'aria-level' ),
10
);
const rootClientId = getBlockRootClientId( clientId );

return {
Expand All @@ -400,7 +403,7 @@ export default function useListViewDropZone() {
rootClientId,
blockIndex: getBlockIndex( clientId ),
element: blockElement,
nestingLevel,
nestingLevel: nestingLevel || undefined,
isDraggedBlock: isBlockDrag
? draggedBlockClientIds.includes( clientId )
: false,
Expand Down