Skip to content

Commit b501426

Browse files
committed
Try to clear up initial state.
1 parent 0584c8a commit b501426

2 files changed

Lines changed: 37 additions & 11 deletions

File tree

packages/components/src/autocomplete/autocompleter-ui.tsx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,33 @@ export function getAutoCompleterUI( autocompleter: WPCompleter ) {
7878
return;
7979
}
8080
if ( !! options.length ) {
81-
debouncedSpeak(
82-
sprintf(
83-
/* translators: %d: number of results. */
84-
_n(
85-
'%d result found, use up and down arrow keys to navigate.',
86-
'%d results found, use up and down arrow keys to navigate.',
81+
if ( filterValue ) {
82+
debouncedSpeak(
83+
sprintf(
84+
/* translators: %d: number of results. */
85+
_n(
86+
'%d result found, use up and down arrow keys to navigate.',
87+
'%d results found, use up and down arrow keys to navigate.',
88+
options.length
89+
),
8790
options.length
8891
),
89-
options.length
90-
),
91-
'assertive'
92-
);
92+
'assertive'
93+
);
94+
} else {
95+
debouncedSpeak(
96+
sprintf(
97+
/* translators: %d: number of results. */
98+
_n(
99+
'%d result loaded. Type to filter or use up and down arrow keys to select the unfiltered result.',
100+
'%d results loaded. Type to filter or use up and down arrow keys to navigate the unfiltered results.',
101+
options.length
102+
),
103+
options.length
104+
),
105+
'assertive'
106+
);
107+
}
93108
} else {
94109
debouncedSpeak( __( 'No results.' ), 'assertive' );
95110
}

test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,18 @@ test.describe( 'Autocomplete (@firefox, @webkit)', () => {
488488
// Get the assertive live region screen reader announcement.
489489
await expect(
490490
page.getByText(
491-
'9 results found, use up and down arrow keys to navigate.'
491+
'9 results loaded. Type to filter or use up and down arrow keys to navigate the unfiltered results.'
492+
)
493+
).toBeVisible();
494+
495+
await page.keyboard.type( 'heading' );
496+
await expect(
497+
page.locator( `role=option[name="Heading"i]` )
498+
).toBeVisible();
499+
// Get the assertive live region screen reader announcement.
500+
await expect(
501+
page.getByText(
502+
'2 results found, use up and down arrow keys to navigate.'
492503
)
493504
).toBeVisible();
494505
} );

0 commit comments

Comments
 (0)