Skip to content

Commit

Permalink
Improve block search input's accessible name and placeholder (#28393)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegohaz authored Feb 16, 2021
1 parent 582a750 commit 0bbc916
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ function InserterMenu( {
setFilterValue( value );
} }
value={ filterValue }
label={ __( 'Search for blocks and patterns' ) }
placeholder={ __( 'Search' ) }
/>
{ !! filterValue && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ export default function QuickInserter( {
onChange={ ( value ) => {
setFilterValue( value );
} }
placeholder={ __( 'Search for a block' ) }
label={ __( 'Search for blocks and patterns' ) }
placeholder={ __( 'Search' ) }
/>
) }

Expand Down
10 changes: 8 additions & 2 deletions packages/block-editor/src/components/inserter/search-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ import { VisuallyHidden, Button } from '@wordpress/components';
import { Icon, search, closeSmall } from '@wordpress/icons';
import { useRef } from '@wordpress/element';

function InserterSearchForm( { className, onChange, value, placeholder } ) {
function InserterSearchForm( {
className,
onChange,
value,
label,
placeholder,
} ) {
const instanceId = useInstanceId( InserterSearchForm );
const searchInput = useRef();

Expand All @@ -27,7 +33,7 @@ function InserterSearchForm( { className, onChange, value, placeholder } ) {
as="label"
htmlFor={ `block-editor-inserter__search-${ instanceId }` }
>
{ placeholder }
{ label || placeholder }
</VisuallyHidden>
<input
ref={ searchInput }
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/specs/widgets/adding-widgets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ describe( 'Widgets screen', () => {

// TODO: The query should be rewritten with role and label.
const inserterSearchBox = await page.waitForSelector(
'input[type="search"][placeholder="Search for a block"]'
'input[type="search"][placeholder="Search"]'
);
expect(
await inserterSearchBox.evaluate(
Expand Down

0 comments on commit 0bbc916

Please sign in to comment.