Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement roving tabindex on the table block toolbar #23252

Merged
merged 2 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions packages/block-library/src/table/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
TextControl,
ToggleControl,
ToolbarGroup,
__experimentalToolbarItem as ToolbarItem,
} from '@wordpress/components';
import {
alignLeft,
Expand Down Expand Up @@ -597,12 +598,17 @@ export class TableEdit extends Component {
<>
<BlockControls>
<ToolbarGroup>
<DropdownMenu
hasArrowIndicator
icon={ table }
label={ __( 'Edit table' ) }
controls={ this.getTableControls() }
/>
<ToolbarItem>
{ ( toggleProps ) => (
<DropdownMenu
hasArrowIndicator
icon={ table }
toggleProps={ toggleProps }
label={ __( 'Edit table' ) }
controls={ this.getTableControls() }
/>
) }
</ToolbarItem>
</ToolbarGroup>
<AlignmentToolbar
label={ __( 'Change column alignment' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ describe( 'Toolbar roving tabindex', () => {
await testGroupKeyboardNavigation( 'Block: Image' );
} );

it( 'ensures table block toolbar uses roving tabindex', async () => {
await insertBlock( 'Table' );
await testBlockToolbarKeyboardNavigation( 'Block: Table' );
// Move focus to the first toolbar item
await page.keyboard.press( 'Home' );
await expectLabelToHaveFocus( 'Change block type or style' );
await page.click( '.blocks-table__placeholder-button' );
await testBlockToolbarKeyboardNavigation( 'Block: Table' );
await wrapCurrentBlockWithGroup();
await testGroupKeyboardNavigation( 'Block: Table' );
} );

it( 'ensures custom html block toolbar uses roving tabindex', async () => {
await insertBlock( 'Custom HTML' );
await testBlockToolbarKeyboardNavigation( 'Block: Custom HTML' );
Expand Down