An open source design system that's fully customizable and agent ready
TypeScript
fix(ComplexSelector, Typeahead, Tokenizer): silence the busy Spinner and announce the busy start once (#7930)
Cindy Zhang9f3ab054c08e
diff --git a/.changeset/typeahead-family-busy-announces-once.md b/.changeset/typeahead-family-busy-announces-once.mdnew file mode 100644index 0000000000..05d2b53e6b--- /dev/null+++ b/.changeset/typeahead-family-busy-announces-once.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] `ComplexSelector`, `Typeahead`, `Tokenizer` and a directly used `BaseTypeahead` announce their busy start ("Loading") once, politely, through the shared announcement channel, and the Spinner they show while busy or while a search is in flight is no longer a live region (`spec:AST-086` FR6, FR8): ComplexSelector's is hidden from assistive technology, and the search Spinner of Typeahead, Tokenizer and BaseTypeahead stays named as an image ("Loading") so the search's busy feedback keeps its name. Before, that Spinner mounted as its own `role="status"` region already named "Loading", which screen readers often skip, and it was a second owner beside the control's `aria-busy`. Inside an open modal dialog the announcement goes to a status region in the dialog. Tests that found the busy Spinner with `getByRole('status', {name: 'Loading'})` should check the control's `aria-busy`, or find the search Spinner with `getByRole('img', {name: 'Loading'})`.++@cixzhangdiff --git a/packages/core/locales/en.json b/packages/core/locales/en.jsonindex 72c90cb2a4..d8e2bea405 100644--- a/packages/core/locales/en.json+++ b/packages/core/locales/en.json@@ -901,7 +901,7 @@},"@astryx.typeahead.loading": {"defaultMessage": "Loading",- "description": "Screen-reader-only name for a spinner shown inside a Typeahead dropdown while suggestions are being fetched. Present-progressive form."+ "description": "Screen-reader-only name for the spinner a Typeahead, Tokenizer or directly used BaseTypeahead shows while suggestions are being fetched; also announced once through the shared announcement channel when each search starts. Present-progressive form."},"@astryx.typeahead.searchResults": {"defaultMessage": "Search results",@@ -1169,7 +1169,7 @@},"@astryx.spinner.loading": {"defaultMessage": "Loading",- "description": "Screen-reader-only default name for a standalone Spinner's role=\"status\" element, used when the consumer supplies neither `aria-label` nor a visible string label; also announced once when a busy field or selector (TextInput, TextArea, Selector, MultiSelector) starts loading, in place of its decorative Spinner. Present-progressive form. Kept separate from `button.loading` and `typeahead.loading` — translations may diverge."+ "description": "Screen-reader-only default name for a standalone Spinner's role=\"status\" element, used when the consumer supplies neither `aria-label` nor a visible string label; also announced once when a busy field or selector (TextInput, TextArea, Selector, MultiSelector, ComplexSelector) starts loading, in place of its decorative Spinner. Present-progressive form. Kept separate from `button.loading` and `typeahead.loading` — translations may diverge."},"@astryx.chatComposerDrawer.expand": {"defaultMessage": "Expand {label}",diff --git a/packages/core/src/ComplexSelector/ComplexSelector.tsx b/packages/core/src/ComplexSelector/ComplexSelector.tsxindex 4337f34ae4..775c519462 100644--- a/packages/core/src/ComplexSelector/ComplexSelector.tsx+++ b/packages/core/src/ComplexSelector/ComplexSelector.tsx@@ -35,6 +35,7 @@ import {import {useDevWarning} from '../hooks/useDevWarning';import {mergeRefs} from '../utils/mergeRefs';import {useMergedRefs} from '../hooks/useMergedRefs';+import {useBusyAnnouncement} from '../hooks/useBusyAnnouncement';import {Field, inputWrapperStyles, type FieldStatusVariant} from '../Field';import {Icon, renderIconSlot, type IconType} from '../Icon';import {Spinner} from '../Spinner';@@ -547,6 +548,9 @@ export function ComplexSelector<Value>({const [isPending, startTransition] = useTransition();const [optimisticValue, setOptimisticValue] = useOptimistic(value);const isBusy = isLoading || isPending;+ // The busy Spinner is decorative; this control announces its busy start+ // (spec:AST-086 FR8).+ useBusyAnnouncement(isBusy, t('@astryx.spinner.loading'), triggerRef);const handlePopoverShow = useCallback(() => {onOpenChange?.(true);@@ -790,7 +794,7 @@ export function ComplexSelector<Value>({{...stylex.props(styles.trigger)}><span {...stylex.props(styles.triggerText)}>{triggerContent}</span></button>- {isBusy && <Spinner size="sm" />}+ {isBusy && <Spinner size="sm" aria-hidden="true" />}<Iconicon="chevronDown"size="sm"diff --git a/packages/core/src/Tokenizer/Tokenizer.test.tsx b/packages/core/src/Tokenizer/Tokenizer.test.tsxindex 528c22cb32..e952597f88 100644--- a/packages/core/src/Tokenizer/Tokenizer.test.tsx+++ b/packages/core/src/Tokenizer/Tokenizer.test.tsx@@ -122,6 +122,17 @@ const userSource: SearchSource = {bootstrap: () => users.slice(0, 3),};+/**+ * The search Spinner: named but not live (family:input-fields FR7,+ * spec:AST-086 FR8), so it is found as an image named "Loading".+ */+function queryBusySpinner(): Element | null {+ return screen.queryByRole('img', {name: 'Loading'});+}+function getBusySpinner(): Element {+ return screen.getByRole('img', {name: 'Loading'});+}+describe('Tokenizer minQueryLength', () => {it('forwards the threshold to the typeahead engine', async () => {const search = vi.fn((query: string) =>@@ -1675,7 +1686,7 @@ describe('Tokenizer end-lane reserve', () => {fireEvent.change(screen.getByRole('combobox'), {target: {value: 'Al'}});});- expect(screen.getByRole('status')).toBeInTheDocument();+ expect(getBusySpinner()).toBeInTheDocument();expect(reserveOf(container)).toBe(`calc(var(--spacing-2) + ${LANE_LOCAL_WIDTH}px)`,);@@ -1774,7 +1785,7 @@ describe('Tokenizer end-lane reserve', () => {// The indicator is up, so the transition really did happen. Scoped by// name: the announcer for result counts is a role="status" live region// too, and it is not the indicator.- expect(screen.getByRole('status', {name: 'Loading'})).toBeInTheDocument();+ expect(getBusySpinner()).toBeInTheDocument();// ...and it cost no token a render.expect(renderedTokens).toEqual([]);@@ -1783,9 +1794,7 @@ describe('Tokenizer end-lane reserve', () => {await Promise.resolve();});await waitFor(() => {- expect(- screen.queryByRole('status', {name: 'Loading'}),- ).not.toBeInTheDocument();+ expect(queryBusySpinner()).not.toBeInTheDocument();});expect(renderedTokens).toEqual([]);});@@ -1823,24 +1832,20 @@ describe('Tokenizer end-lane reserve', () => {fireEvent.focus(input);await waitFor(() => {- expect(screen.getByRole('status', {name: 'Loading'})).toBeInTheDocument();+ expect(getBusySpinner()).toBeInTheDocument();});fireEvent.click(screen.getByRole('button', {name: 'Add Token'}));await waitFor(() => {- expect(- screen.queryByRole('status', {name: 'Loading'}),- ).not.toBeInTheDocument();+ expect(queryBusySpinner()).not.toBeInTheDocument();});await act(async () => {settle([]);await Promise.resolve();});- expect(- screen.queryByRole('status', {name: 'Loading'}),- ).not.toBeInTheDocument();+ expect(queryBusySpinner()).not.toBeInTheDocument();});it('shares one observer across every field on the page', () => {diff --git a/packages/core/src/Tokenizer/Tokenizer.tsx b/packages/core/src/Tokenizer/Tokenizer.tsxindex c479229b8a..8d5bd10a6c 100644--- a/packages/core/src/Tokenizer/Tokenizer.tsx+++ b/packages/core/src/Tokenizer/Tokenizer.tsx@@ -23,6 +23,7 @@ import React, {useRef,useState,type ReactNode,+ type RefObject,} from 'react';import * as stylex from '@stylexjs/stylex';import {@@ -37,6 +38,7 @@ import {useFieldInputStyling,} from '../Field/fieldParts';import {useMergedRefs} from '../hooks/useMergedRefs';+import {useBusyAnnouncement} from '../hooks/useBusyAnnouncement';import type {SizeValue} from '../utils/types';import {BaseTypeahead} from '../Typeahead/BaseTypeahead';import {useSize} from '../SizeContext/SizeContext';@@ -521,6 +523,7 @@ function EndLane({laneRef,laneXStyle,loadingLabel,+ anchorRef,hasStaticContent,children,}: {@@ -528,16 +531,21 @@ function EndLane({laneRef: (node: HTMLElement | null) => void;laneXStyle: stylex.StyleXStyles[];loadingLabel: string;+ anchorRef: RefObject<Element | null>;hasStaticContent: boolean;children: ReactNode;}) {const isBusy = useIsBusy(lane);+ // The search Spinner stays named (family:input-fields FR7) but is not a+ // live region; the field announces each search's busy start instead+ // (spec:AST-086 FR8).+ useBusyAnnouncement(isBusy, loadingLabel, anchorRef);if (!isBusy && !hasStaticContent) {return null;}return (<div ref={laneRef} {...stylex.props(laneXStyle)}>- {isBusy && <Spinner size="sm" aria-label={loadingLabel} />}+ {isBusy && <Spinner size="sm" aria-label={loadingLabel} role="img" />}{children}</div>);@@ -1084,6 +1092,7 @@ export function Tokenizer<T extends SearchableItem>({laneRef={laneRef}laneXStyle={[styles.endSection, endSectionSizeStyles[size]]}loadingLabel={t('@astryx.typeahead.loading')}+ anchorRef={wrapperRef}hasStaticContent={hasStaticEndLane}>{endContent}{hasClearButton && (diff --git a/packages/core/src/Typeahead/BaseTypeahead.tsx b/packages/core/src/Typeahead/BaseTypeahead.tsxindex 40ecb8e53f..c2b341c154 100644--- a/packages/core/src/Typeahead/BaseTypeahead.tsx+++ b/packages/core/src/Typeahead/BaseTypeahead.tsx@@ -62,6 +62,7 @@ import {themeProps} from '../utils/themeProps';import {useTranslator} from '../i18n';import {useMergedRefs} from '../hooks/useMergedRefs';+import {useBusyAnnouncement} from '../hooks/useBusyAnnouncement';import {layerViewportInset} from '../Layer/layerViewportInset.stylex';import {clampInlineSize} from '../Layer/clampInlineSize';// =============================================================================@@ -561,6 +562,14 @@ export const BaseTypeahead = function BaseTypeahead<T extends SearchableItem>({// A wrapper that owns the inline-end lane subscribes through context; see// busyIndicatorLane.tsx for why this is not a prop.const busyLane = useBusyIndicatorLane();+ // Without a wrapper that took the indicator over, this input announces each+ // search's busy start (spec:AST-086 FR8); its Spinner stays named but is not+ // a live region (family:input-fields FR7).+ useBusyAnnouncement(+ isLoading && busyLane == null,+ t('@astryx.typeahead.loading'),+ inputRef,+ );const onLoadingChangeRef = useRef(busyLane?.onBusyChange);useIsomorphicLayoutEffect(() => {onLoadingChangeRef.current = busyLane?.onBusyChange;@@ -1218,7 +1227,11 @@ export const BaseTypeahead = function BaseTypeahead<T extends SearchableItem>({/>{isLoading && busyLane == null && (<span {...stylex.props(styles.loadingStatus)}>- <Spinner size="sm" aria-label={t('@astryx.typeahead.loading')} />+ <Spinner+ size="sm"+ aria-label={t('@astryx.typeahead.loading')}+ role="img"+ /></span>)}{popover.render(diff --git a/packages/core/src/Typeahead/Typeahead.test.tsx b/packages/core/src/Typeahead/Typeahead.test.tsxindex 729a7a4a03..67e7d6fa12 100644--- a/packages/core/src/Typeahead/Typeahead.test.tsx+++ b/packages/core/src/Typeahead/Typeahead.test.tsx@@ -99,6 +99,17 @@ const fruitSource: SearchSource = {bootstrap: () => fruits.slice(0, 3),};+/**+ * The search Spinner: named but not live (family:input-fields FR7,+ * spec:AST-086 FR8), so it is found as an image named "Loading".+ */+function queryBusySpinner(): Element | null {+ return screen.queryByRole('img', {name: 'Loading'});+}+function getBusySpinner(): Element {+ return screen.getByRole('img', {name: 'Loading'});+}+describe('BaseTypeahead', () => {it('renders input with combobox role', () => {render(@@ -929,14 +940,12 @@ describe('BaseTypeahead hasEntriesOnFocus', () => {fireEvent.change(input, {target: {value: 'a'}});await waitFor(() => {- expect(screen.getByRole('status', {name: 'Loading'})).toBeInTheDocument();+ expect(getBusySpinner()).toBeInTheDocument();});fireEvent.change(input, {target: {value: ''}});await waitFor(() => {- expect(- screen.queryByRole('status', {name: 'Loading'}),- ).not.toBeInTheDocument();+ expect(queryBusySpinner()).not.toBeInTheDocument();});await act(async () => {@@ -966,16 +975,14 @@ describe('BaseTypeahead hasEntriesOnFocus', () => {fireEvent.focus(input);await waitFor(() => {- expect(screen.getByRole('status', {name: 'Loading'})).toBeInTheDocument();+ expect(getBusySpinner()).toBeInTheDocument();});await act(async () => {settle([]);await Promise.resolve();});- expect(- screen.queryByRole('status', {name: 'Loading'}),- ).not.toBeInTheDocument();+ expect(queryBusySpinner()).not.toBeInTheDocument();});it('clears the loading state when the search source is replaced during an in-flight load', async () => {@@ -1004,7 +1011,7 @@ describe('BaseTypeahead hasEntriesOnFocus', () => {fireEvent.focus(input);await waitFor(() => {- expect(screen.getByRole('status', {name: 'Loading'})).toBeInTheDocument();+ expect(getBusySpinner()).toBeInTheDocument();});rerender(@@ -1017,18 +1024,14 @@ describe('BaseTypeahead hasEntriesOnFocus', () => {);await waitFor(() => {- expect(- screen.queryByRole('status', {name: 'Loading'}),- ).not.toBeInTheDocument();+ expect(queryBusySpinner()).not.toBeInTheDocument();});await act(async () => {settle([]);await Promise.resolve();});- expect(- screen.queryByRole('status', {name: 'Loading'}),- ).not.toBeInTheDocument();+ expect(queryBusySpinner()).not.toBeInTheDocument();});it('keeps the loading state under StrictMode for a pending autofocus bootstrap', async () => {@@ -1052,15 +1055,13 @@ describe('BaseTypeahead hasEntriesOnFocus', () => {</StrictMode>,);- expect(screen.getByRole('status', {name: 'Loading'})).toBeInTheDocument();+ expect(getBusySpinner()).toBeInTheDocument();await act(async () => {settle([]);await Promise.resolve();});- expect(- screen.queryByRole('status', {name: 'Loading'}),- ).not.toBeInTheDocument();+ expect(queryBusySpinner()).not.toBeInTheDocument();});let settlePendingTransitionA: (items: SearchableItem[]) => void = () => {};@@ -1125,7 +1126,7 @@ describe('BaseTypeahead hasEntriesOnFocus', () => {await waitFor(() => {expect(input).toHaveAttribute('aria-busy', 'true');});- expect(screen.getByRole('status', {name: 'Loading'})).toBeInTheDocument();+ expect(getBusySpinner()).toBeInTheDocument();// Create the pending promise for suspensionisSuspended = true;@@ -1160,9 +1161,7 @@ describe('BaseTypeahead hasEntriesOnFocus', () => {// The combobox must not keep aria-busy and the spinner must be goneexpect(input).not.toHaveAttribute('aria-busy');- expect(- screen.queryByRole('status', {name: 'Loading'}),- ).not.toBeInTheDocument();+ expect(queryBusySpinner()).not.toBeInTheDocument();});it('shows bootstrap results on mouse click', async () => {@@ -1443,7 +1442,7 @@ describe('BaseTypeahead minQueryLength', () => {fireEvent.change(input, {target: {value: 'App'}});await waitFor(() => {- expect(screen.getByRole('status', {name: 'Loading'})).toBeInTheDocument();+ expect(getBusySpinner()).toBeInTheDocument();});expect(input).toHaveAttribute('aria-busy', 'true');@@ -1453,9 +1452,7 @@ describe('BaseTypeahead minQueryLength', () => {await Promise.resolve();});- expect(- screen.queryByRole('status', {name: 'Loading'}),- ).not.toBeInTheDocument();+ expect(queryBusySpinner()).not.toBeInTheDocument();expect(input).not.toHaveAttribute('aria-busy');expect(input).toHaveAttribute('aria-expanded', 'false');});@@ -2185,12 +2182,12 @@ describe('busy indicator ownership', () => {};};- it('renders its own named status for a direct caller', async () => {+ it('renders its own indicator for a direct caller', async () => {// BaseTypeaheadProps is re-exported from the package entry point, so the// base has direct callers this repo cannot see. They painted no indicator- // of their own — the base did it for them — so it keeps doing it, and the- // status stays a named one rather than a bare aria-busy that only reaches- // assistive tech.+ // of their own — the base did it for them — so it keeps doing it. The+ // Spinner is decorative and the base announces the search's busy start+ // through the shared channel (spec:AST-086 FR8).const {source, settle} = pendingSource();render(<BaseTypeahead@@ -2204,22 +2201,18 @@ describe('busy indicator ownership', () => {fireEvent.change(input, {target: {value: 'App'}});await waitFor(() => {- expect(screen.getByRole('status', {name: 'Loading'})).toBeInTheDocument();+ expect(getBusySpinner()).toBeInTheDocument();});// A Spinner, not the static clock glyph this used to render: `clock`// means *time* everywhere else in core, and nothing about it moved while// a search was out.- expect(- screen.getByRole('status', {name: 'Loading'}).querySelector('svg'),- ).toBeInTheDocument();+ expect(getBusySpinner().querySelector('svg')).toBeInTheDocument();await act(async () => {settle();await Promise.resolve();});- expect(- screen.queryByRole('status', {name: 'Loading'}),- ).not.toBeInTheDocument();+ expect(queryBusySpinner()).not.toBeInTheDocument();});it('hands the indicator over to a field that takes it, and renders none itself', async () => {@@ -2250,9 +2243,7 @@ describe('busy indicator ownership', () => {});// Scoped by name: the announcer for result counts is a role="status"// live region too, and it is not the indicator.- expect(- screen.queryByRole('status', {name: 'Loading'}),- ).not.toBeInTheDocument();+ expect(queryBusySpinner()).not.toBeInTheDocument();expect(onLoadingChange).toHaveBeenLastCalledWith(true);await act(async () => {diff --git a/packages/core/src/Typeahead/Typeahead.tsx b/packages/core/src/Typeahead/Typeahead.tsxindex a33912c4b3..1d8d71653d 100644--- a/packages/core/src/Typeahead/Typeahead.tsx+++ b/packages/core/src/Typeahead/Typeahead.tsx@@ -25,6 +25,7 @@ import React, {useMemo,useState,type ReactNode,+ type RefObject,} from 'react';import * as stylex from '@stylexjs/stylex';import {@@ -70,6 +71,7 @@ import {themeProps} from '../utils/themeProps';import {useTranslator} from '../i18n';import {useMergedRefs} from '../hooks/useMergedRefs';+import {useBusyAnnouncement} from '../hooks/useBusyAnnouncement';export type {InputStatus as TypeaheadStatus,InputStatusType as TypeaheadStatusType,@@ -349,19 +351,25 @@ const wrapperSizeStyles = stylex.create({function EndLane({lane,loadingLabel,+ anchorRef,clear,}: {lane: BusyIndicatorLane;loadingLabel: string;+ anchorRef: RefObject<Element | null>;clear: ReactNode;}) {const isBusy = useIsBusy(lane);+ // The search Spinner stays named (family:input-fields FR7) but is not a+ // live region; the field announces each search's busy start instead+ // (spec:AST-086 FR8).+ useBusyAnnouncement(isBusy, loadingLabel, anchorRef);if (!isBusy && clear == null) {return null;}return (<div {...stylex.props(styles.endLane)}>- {isBusy && <Spinner size="sm" aria-label={loadingLabel} />}+ {isBusy && <Spinner size="sm" aria-label={loadingLabel} role="img" />}{clear}</div>);@@ -679,6 +687,7 @@ export function Typeahead<T extends SearchableItem>({<EndLanelane={busyLane}loadingLabel={t('@astryx.typeahead.loading')}+ anchorRef={wrapperRef}clear={hasClear && value && !isDisabled ? (<InputClearButtondiff --git a/packages/core/src/__tests__/BusyOwnerAnnouncement.test.tsx b/packages/core/src/__tests__/BusyOwnerAnnouncement.test.tsxindex 9c35b74482..7284d0cc08 100644--- a/packages/core/src/__tests__/BusyOwnerAnnouncement.test.tsx+++ b/packages/core/src/__tests__/BusyOwnerAnnouncement.test.tsx@@ -10,11 +10,15 @@import {StrictMode, useEffect, useRef, type ReactElement} from 'react';import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';-import {act, render, screen} from '@testing-library/react';+import {act, fireEvent, render, screen} from '@testing-library/react';import {TextInput} from '../TextInput';import {TextArea} from '../TextArea';import {Selector} from '../Selector';import {MultiSelector} from '../MultiSelector';+import {ComplexSelector} from '../ComplexSelector';+import {BaseTypeahead, Typeahead} from '../Typeahead';+import type {SearchableItem, SearchSource} from '../Typeahead';+import {Tokenizer} from '../Tokenizer';const announce = vi.fn();vi.mock('../hooks/useAnnounce', async importOriginal => ({@@ -75,6 +79,63 @@ const OWNERS: ReadonlyArray</>),],+ [+ 'ComplexSelector',+ isLoading => (+ <ComplexSelector label="Fruit blend" value="Apple" isLoading={isLoading}>+ {() => <div>Options</div>}+ </ComplexSelector>+ ),+ ],+];++/** A search source whose searches stay in flight until the test settles them. */+function pendingSource(): SearchSource<SearchableItem> {+ return {+ search: async () => new Promise<SearchableItem[]>(() => {}),+ bootstrap: () => [],+ };+}++/** Owners whose busy state is a search in flight, started by typing. */+const SEARCH_OWNERS: ReadonlyArray<+ readonly [string, (source: SearchSource<SearchableItem>) => ReactElement]+> = [+ [+ 'Typeahead',+ source => (+ <Typeahead+ label="User"+ searchSource={source}+ value={null}+ onChange={() => {}}+ debounceMs={0}+ />+ ),+ ],+ [+ 'Tokenizer',+ source => (+ <Tokenizer+ label="Users"+ searchSource={source}+ value={[]}+ onChange={() => {}}+ debounceMs={0}+ />+ ),+ ],+ [+ 'BaseTypeahead',+ source => (+ <BaseTypeahead+ searchSource={source}+ value={null}+ onChange={() => {}}+ debounceMs={0}+ />+ ),+ ],];/** Calls that announced the busy start, ignoring each control's other messages. */@@ -188,3 +249,70 @@ describe.each(OWNERS)(});},);++describe.each(SEARCH_OWNERS)(+ '%s search busy state (spec:AST-086)',+ (_name, renderOwner) => {+ it('keeps its search Spinner named but not live, and announces the search start once (FR6, FR8)', async () => {+ const {container} = render(strict(renderOwner(pendingSource())));+ await nextFrame();+ expect(busyAnnouncements()).toEqual([]);+ act(() => {+ fireEvent.change(screen.getByRole('combobox'), {target: {value: 'Al'}});+ });+ await nextFrame();+ // Named but not live (family:input-fields FR7, FR8).+ const spinner = container.querySelector('.astryx-spinner');+ expect(spinner).toHaveAttribute('role', 'img');+ expect(screen.getByRole('img', {name: 'Loading'})).toBe(spinner);+ expect(screen.queryByRole('status', {name: 'Loading'})).toBeNull();+ expect(busyAnnouncements()).toEqual([['Loading', 'polite']]);+ });++ it('announces each new search start again (FR6)', async () => {+ render(renderOwner(pendingSource()));+ const input = screen.getByRole('combobox');+ act(() => {+ fireEvent.change(input, {target: {value: 'Al'}});+ });+ await nextFrame();+ // Clearing the query ends the search; typing again starts a new one.+ act(() => {+ fireEvent.change(input, {target: {value: ''}});+ });+ await nextFrame();+ act(() => {+ fireEvent.change(input, {target: {value: 'Be'}});+ });+ await nextFrame();+ expect(busyAnnouncements()).toEqual([+ ['Loading', 'polite'],+ ['Loading', 'polite'],+ ]);+ });++ it('announces the search start inside an open modal dialog, not the body channel', async () => {+ const matches = Element.prototype.matches;+ vi.spyOn(Element.prototype, 'matches').mockImplementation(function (+ this: Element,+ selector: string,+ ) {+ return selector === ':modal'+ ? this instanceof HTMLDialogElement && this.open+ : matches.call(this, selector);+ });+ render(<dialog open>{renderOwner(pendingSource())}</dialog>);+ act(() => {+ fireEvent.change(screen.getByRole('combobox'), {target: {value: 'Al'}});+ });+ await nextFrame();+ await nextFrame();+ const dialog = document.querySelector('dialog') as HTMLDialogElement;+ expect(+ dialog.querySelector('[data-astryx-modal-busy-region]'),+ ).toHaveTextContent('Loading');+ expect(busyAnnouncements()).toEqual([]);+ vi.restoreAllMocks();+ });+ },+);