diff --git a/package-lock.json b/package-lock.json
index f839767eb84728..d8eaa3128fea1e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10999,6 +10999,7 @@
"react-autosize-textarea": "^3.0.2",
"react-spring": "^8.0.19",
"react-transition-group": "^2.9.0",
+ "reakit": "1.1.0",
"redux-multi": "^0.1.12",
"refx": "^3.0.0",
"rememo": "^3.0.0",
diff --git a/packages/block-editor/package.json b/packages/block-editor/package.json
index 0d96729e7465da..4fafc861af5cc2 100644
--- a/packages/block-editor/package.json
+++ b/packages/block-editor/package.json
@@ -62,6 +62,7 @@
"react-autosize-textarea": "^3.0.2",
"react-spring": "^8.0.19",
"react-transition-group": "^2.9.0",
+ "reakit": "1.1.0",
"redux-multi": "^0.1.12",
"refx": "^3.0.0",
"rememo": "^3.0.0",
diff --git a/packages/block-editor/src/components/block-types-list/index.js b/packages/block-editor/src/components/block-types-list/index.js
index 60eb915c925a60..a6b6b734bc1bc0 100644
--- a/packages/block-editor/src/components/block-types-list/index.js
+++ b/packages/block-editor/src/components/block-types-list/index.js
@@ -1,7 +1,13 @@
+/**
+ * External dependencies
+ */
+import { Composite, useCompositeState } from 'reakit';
+
/**
* WordPress dependencies
*/
import { getBlockMenuDefaultClassName } from '@wordpress/blocks';
+import { useEffect } from '@wordpress/element';
/**
* Internal dependencies
@@ -14,8 +20,19 @@ function BlockTypesList( {
onSelect,
onHover = () => {},
children,
+ label,
} ) {
+ const composite = useCompositeState();
const normalizedItems = includeVariationsInInserterItems( items );
+ const orderId = normalizedItems.reduce(
+ ( acc, item ) => acc + '--' + item.id,
+ ''
+ );
+
+ // This ensures the composite state refreshes when the list order changes.
+ useEffect( () => {
+ composite.unstable_sort();
+ }, [ composite.unstable_sort, orderId ] );
return (
/*
@@ -23,7 +40,12 @@ function BlockTypesList( {
* Safari+VoiceOver won't announce the list otherwise.
*/
/* eslint-disable jsx-a11y/no-redundant-roles */
-
+
{ normalizedItems.map( ( item ) => {
return (
onHover( null ) }
isDisabled={ item.isDisabled }
title={ item.title }
+ composite={ composite }
/>
);
} ) }
{ children }
-
+
/* eslint-enable jsx-a11y/no-redundant-roles */
);
}
diff --git a/packages/block-editor/src/components/inserter-list-item/index.js b/packages/block-editor/src/components/inserter-list-item/index.js
index b4c8e40cf5efea..7dfd41cf98cbea 100644
--- a/packages/block-editor/src/components/inserter-list-item/index.js
+++ b/packages/block-editor/src/components/inserter-list-item/index.js
@@ -2,6 +2,7 @@
* External dependencies
*/
import classnames from 'classnames';
+import { CompositeItem } from 'reakit';
/**
* WordPress dependencies
@@ -19,6 +20,7 @@ function InserterListItem( {
isDisabled,
title,
className,
+ composite,
...props
} ) {
const itemIconStyle = icon
@@ -29,8 +31,11 @@ function InserterListItem( {
: {};
return (
-
-
-
+
+
);
}
diff --git a/packages/block-editor/src/components/inserter/block-types-tab.js b/packages/block-editor/src/components/inserter/block-types-tab.js
index ec604fe1c77c64..e6b7c630bad372 100644
--- a/packages/block-editor/src/components/inserter/block-types-tab.js
+++ b/packages/block-editor/src/components/inserter/block-types-tab.js
@@ -132,6 +132,7 @@ export function BlockTypesTab( {
items={ filteredItems }
onSelect={ onSelectItem }
onHover={ onHover }
+ label={ __( 'Child Blocks' ) }
/>
) }
@@ -145,6 +146,7 @@ export function BlockTypesTab( {
items={ suggestedItems }
onSelect={ onSelectItem }
onHover={ onHover }
+ label={ _x( 'Most used', 'blocks' ) }
/>
) }
@@ -165,6 +167,7 @@ export function BlockTypesTab( {
items={ categoryItems }
onSelect={ onSelectItem }
onHover={ onHover }
+ label={ category.title }
/>
);
@@ -179,6 +182,7 @@ export function BlockTypesTab( {
items={ uncategorizedItems }
onSelect={ onSelectItem }
onHover={ onHover }
+ label={ __( 'Uncategorized' ) }
/>
) }
@@ -200,6 +204,7 @@ export function BlockTypesTab( {
items={ collectionItems }
onSelect={ onSelectItem }
onHover={ onHover }
+ label={ collection.title }
/>
);
diff --git a/packages/block-editor/src/components/inserter/quick-inserter.js b/packages/block-editor/src/components/inserter/quick-inserter.js
index f37728aa0ae61f..39d31dad3ffe7e 100644
--- a/packages/block-editor/src/components/inserter/quick-inserter.js
+++ b/packages/block-editor/src/components/inserter/quick-inserter.js
@@ -79,6 +79,7 @@ function QuickInserterList( {
items={ shownBlockTypes }
onSelect={ onSelectBlockType }
onHover={ onHover }
+ label={ __( 'Blocks' ) }
/>
) }
diff --git a/packages/block-editor/src/components/inserter/reusable-blocks-tab.js b/packages/block-editor/src/components/inserter/reusable-blocks-tab.js
index ebec296e75526c..b9aec00ff32a3d 100644
--- a/packages/block-editor/src/components/inserter/reusable-blocks-tab.js
+++ b/packages/block-editor/src/components/inserter/reusable-blocks-tab.js
@@ -67,6 +67,11 @@ function ReusableBlocksList( {
items={ filteredItems }
onSelect={ onSelectItem }
onHover={ onHover }
+ label={
+ filterValue
+ ? __( 'Search Results' )
+ : __( 'Reusable blocks' )
+ }
/>
);
diff --git a/packages/e2e-tests/specs/editor/various/adding-blocks.test.js b/packages/e2e-tests/specs/editor/various/adding-blocks.test.js
index aab95bc526917c..535631af50e37b 100644
--- a/packages/e2e-tests/specs/editor/various/adding-blocks.test.js
+++ b/packages/e2e-tests/specs/editor/various/adding-blocks.test.js
@@ -158,7 +158,6 @@ describe( 'adding blocks', () => {
// Tab to the block list
await page.keyboard.press( 'Tab' );
- await page.keyboard.press( 'Tab' );
// Expect the block list to be the active element.
activeElementClassList = await page.evaluate(