Skip to content

Commit

Permalink
Implement roving tabindex on the Custom HTML block toolbar (#23277)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegohaz authored Jun 18, 2020
1 parent 75176cd commit 0f55499
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/block-library/src/html/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import {
PlainText,
transformStyles,
} from '@wordpress/block-editor';
import { Button, Disabled, SandBox, ToolbarGroup } from '@wordpress/components';
import {
ToolbarButton,
Disabled,
SandBox,
ToolbarGroup,
} from '@wordpress/components';
import { withSelect } from '@wordpress/data';

class HTMLEdit extends Component {
Expand Down Expand Up @@ -57,20 +62,20 @@ class HTMLEdit extends Component {
<div className="wp-block-html">
<BlockControls>
<ToolbarGroup>
<Button
<ToolbarButton
className="components-tab-button"
isPressed={ ! isPreview }
onClick={ this.switchToHTML }
>
<span>HTML</span>
</Button>
<Button
</ToolbarButton>
<ToolbarButton
className="components-tab-button"
isPressed={ isPreview }
onClick={ this.switchToPreview }
>
<span>{ __( 'Preview' ) }</span>
</Button>
</ToolbarButton>
</ToolbarGroup>
</BlockControls>
<Disabled.Consumer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,11 @@ describe( 'Toolbar roving tabindex', () => {
await wrapCurrentBlockWithGroup();
await testGroupKeyboardNavigation( 'Block: Image' );
} );

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

0 comments on commit 0f55499

Please sign in to comment.