An open source design system that's fully customizable and agent ready
TypeScript
fix(Tokenizer): wrap tokens before the clear-all lane (#7375)
Harjoth Kharad8e3b386affb
diff --git a/.changeset/tokenizer-tokens-wrap-before-the-clear-all-butto-a99p.md b/.changeset/tokenizer-tokens-wrap-before-the-clear-all-butto-a99p.mdnew file mode 100644index 0000000000..cf353bd282--- /dev/null+++ b/.changeset/tokenizer-tokens-wrap-before-the-clear-all-butto-a99p.md@@ -0,0 +1,6 @@+---+'@astryxdesign/core': patch+---++[fix] Tokenizer: tokens wrap before the clear-all button and busy indicator instead of running under them, including PowerSearch filters. While the field has tokens and can search, the busy indicator's space stays reserved, so a search starting or settling does not move token rows+@harjothkharadiff --git a/apps/storybook/stories/PowerSearch.stories.tsx b/apps/storybook/stories/PowerSearch.stories.tsxindex 1c8a709b9b..f858f28564 100644--- a/apps/storybook/stories/PowerSearch.stories.tsx+++ b/apps/storybook/stories/PowerSearch.stories.tsx@@ -557,7 +557,7 @@ export const NearFullTokenRow: Story = {{field: 'title',operator: 'contains',- value: {type: 'string', value: 'aaaaaaaaaaaaaaaaaa'},+ value: {type: 'string', value: 'aaaaaaaaaaaaa'},},]);return (diff --git a/apps/storybook/stories/Tokenizer.stories.tsx b/apps/storybook/stories/Tokenizer.stories.tsxindex 0e5bc98aa7..355c0cb98e 100644--- a/apps/storybook/stories/Tokenizer.stories.tsx+++ b/apps/storybook/stories/Tokenizer.stories.tsx@@ -5,6 +5,7 @@ import type {Meta, StoryObj} from '@storybook/react';import {Tokenizer} from '@astryxdesign/core/Tokenizer';import type {SearchableItem, SearchSource} from '@astryxdesign/core/Typeahead';import {Button} from '@astryxdesign/core/Button';+import {Token} from '@astryxdesign/core/Token';import {MagnifyingGlassIcon} from '@heroicons/react/24/outline';// Sample data@@ -548,3 +549,43 @@ export const RtlEndLane: Story = {},name: 'RTL end lane (token + clear)',};++const longToken: SearchableItem = {+ id: 'long',+ label: 'Status: is In Progress, Blocked, or Waiting for Review',+};++/**+ * One token wider than the row, beside the clear-all lane, as the default pill+ * and through `renderToken`. Both must truncate short of the lane rather than+ * run underneath it.+ */+export const LongTokenEndLane: Story = {+ render: args => (+ <div style={{display: 'grid', gap: 16}}>+ <Tokenizer+ {...args}+ searchSource={userSource}+ value={[longToken]}+ onChange={() => {}}+ hasClear+ />+ <Tokenizer+ {...args}+ label="Custom token"+ searchSource={userSource}+ value={[longToken]}+ onChange={() => {}}+ hasClear+ renderToken={(item, onRemove) => (+ <Token label={item.label} onRemove={onRemove} />+ )}+ />+ </div>+ ),+ args: {+ label: 'Filters',+ placeholder: 'Add a filter...',+ },+ name: 'Long token beside the end lane',+};diff --git a/packages/core/src/Tokenizer/Tokenizer.test.tsx b/packages/core/src/Tokenizer/Tokenizer.test.tsxindex e952597f88..38d975ad89 100644--- a/packages/core/src/Tokenizer/Tokenizer.test.tsx+++ b/packages/core/src/Tokenizer/Tokenizer.test.tsx@@ -1692,6 +1692,27 @@ describe('Tokenizer end-lane reserve', () => {);});+ it('keeps token rows, not only the input, short of the lane', () => {+ // The lane is out of flow, so a token reaching the end of the first row+ // ran under the clear button. The field's own inline-end padding spends+ // the reserve, and every row of tokens wraps inside it. Real geometry is+ // proved in TokenizerEndLane.a11y.chromium.spec.ts.+ const {container} = render(+ <Tokenizer+ label="Users"+ searchSource={userSource}+ value={[users[0]]}+ onChange={() => {}}+ hasClear+ />,+ );+ const field = laneHost(container);+ expect(field).not.toBeNull();+ expect(getComputedStyle(field!).paddingInlineEnd).toContain(+ '--_tokenizer-end-lane-reserve',+ );+ });+it('does not pad the input on the collapsed paths', () => {// Collapsed: with tokens truncated the input is given no width to pad —// `inputAtMax` zeroes its padding outright — so a reserve there would be@@ -1707,16 +1728,13 @@ describe('Tokenizer end-lane reserve', () => {tokenOverflowBehavior="unfocusedInline"/>,);+ // The collapsed row keeps the Spinner's slot, so the lane is up and+ // publishing; the input still must not spend the reserve.+ expect(reserveOf(container)).toBeTruthy();const input = screen.getByRole('combobox');- expect(input.className).not.toBe('');- // The reserve is the only rule that reads the lane variable; the- // collapsed input must not carry it.- const reserveClasses = new Set(- (laneHost(container)?.className ?? '').split(' '),+ expect(getComputedStyle(input).paddingInlineEnd).not.toContain(+ '--_tokenizer-end-lane-reserve',);- expect(- [...input.classList].some(c => reserveClasses.has(c) && c !== ''),- ).toBe(false);});it('costs no commit of its own across a whole search', async () => {diff --git a/packages/core/src/Tokenizer/Tokenizer.tsx b/packages/core/src/Tokenizer/Tokenizer.tsxindex 8d5bd10a6c..16627c2a24 100644--- a/packages/core/src/Tokenizer/Tokenizer.tsx+++ b/packages/core/src/Tokenizer/Tokenizer.tsx@@ -275,8 +275,9 @@ const TOKEN_ROW_INSET = `calc(${spacingVars['--spacing-1']} - 1px)`;// InputClearButton grows 2px past its visible box under `(pointer: coarse)`.// Keep this maximum reserve in sync with Field/InputClearButton.tsx.const INPUT_CLEAR_COARSE_POINTER_OUTSET = '2px';-// Kept in sync with useEndLaneReserve: inputCompact reads the custom property-// directly so its empty-query pseudo-class can suppress the inner reserve.+// Kept in sync with useEndLaneReserve: wrapperWithTokens and inputCompact read+// the custom property directly, to keep token rows and the empty-query hit+// surface short of the lane.const END_LANE_RESERVE_VAR = '--_tokenizer-end-lane-reserve';const styles = stylex.create({@@ -297,6 +298,10 @@ const styles = stylex.create({// = 8 - 4 - 1 = 3px.paddingBlock: TOKEN_ROW_INSET,paddingInline: TOKEN_ROW_INSET,+ // The end lane is out of flow, so tokens would wrap under it. Every row+ // stops short of the measured lane instead; with no lane up the variable+ // is absent and this is the ordinary inset.+ paddingInlineEnd: `calc(${TOKEN_ROW_INSET} + var(${END_LANE_RESERVE_VAR}, 0px))`,// Row gap must match paddingBlock so wrapped rows look evenly spaced.rowGap: TOKEN_ROW_INSET,},@@ -310,6 +315,9 @@ const styles = stylex.create({token: {display: 'flex',flexShrink: 0,+ // A renderToken wrapper sizes to its content; cap it at the row so the+ // pill inside truncates instead of running past the field.+ maxWidth: '100%',position: 'relative',zIndex: 1,},@@ -325,6 +333,14 @@ const styles = stylex.create({flexShrink: 0,zIndex: 1,},+ idleSpinner: {+ // Hides the Spinner's own box too, which a theme may paint, and covers+ // engines without content-visibility. Both keep the box's size.+ visibility: 'hidden',+ // Skips the ring's rendering, and with it the infinite arc animation,+ // while the root keeps its own explicit, themed width and height.+ contentVisibility: 'hidden',+ },inputAtMax: {width: 0,minWidth: 0,@@ -367,7 +383,8 @@ const styles = stylex.create({':placeholder-shown': 0,},paddingInlineEnd: {- default: `var(${END_LANE_RESERVE_VAR}, 0px)`,+ // wrapperWithTokens already keeps the in-flow input short of the lane.+ default: 0,':placeholder-shown': spacingVars['--spacing-1'],},textAlign: {@@ -517,6 +534,13 @@ const CREATABLE_ID_PREFIX = '__xds_create__';** Renders nothing when the lane would be empty, so `useEndLaneReserve` sees no* element, publishes no width, and the input keeps its full content box.+ *+ * With `hasBusySlot` the Spinner stays mounted while idle, unrendered, not+ * animating and out of the accessibility tree, so its box keeps the themed+ * Spinner's own size.+ * Token rows reserve the lane's measured width, so a Spinner that came and+ * went with the search would re-wrap them, and widen a content-sized field,+ * on every search.*/function EndLane({lane,@@ -525,6 +549,7 @@ function EndLane({loadingLabel,anchorRef,hasStaticContent,+ hasBusySlot,children,}: {lane: BusyIndicatorLane;@@ -533,6 +558,7 @@ function EndLane({loadingLabel: string;anchorRef: RefObject<Element | null>;hasStaticContent: boolean;+ hasBusySlot: boolean;children: ReactNode;}) {const isBusy = useIsBusy(lane);@@ -540,12 +566,23 @@ function EndLane({// live region; the field announces each search's busy start instead// (spec:AST-086 FR8).useBusyAnnouncement(isBusy, loadingLabel, anchorRef);- if (!isBusy && !hasStaticContent) {+ if (!isBusy && !hasStaticContent && !hasBusySlot) {return null;}return (<div ref={laneRef} {...stylex.props(laneXStyle)}>- {isBusy && <Spinner size="sm" aria-label={loadingLabel} role="img" />}+ {(isBusy || hasBusySlot) && (+ <Spinner+ // Remounts when a search starts, so the ring syncs its phase on+ // mount exactly as a newly shown Spinner did before.+ key={isBusy ? 'busy' : 'idle'}+ size="sm"+ aria-label={loadingLabel}+ role="img"+ aria-hidden={isBusy ? undefined : true}+ xstyle={isBusy ? undefined : styles.idleSpinner}+ />+ )}{children}</div>);@@ -1093,7 +1130,11 @@ export function Tokenizer<T extends SearchableItem>({laneXStyle={[styles.endSection, endSectionSizeStyles[size]]}loadingLabel={t('@astryx.typeahead.loading')}anchorRef={wrapperRef}- hasStaticContent={hasStaticEndLane}>+ hasStaticContent={hasStaticEndLane}+ // Wherever a search can run beside tokens: enabled and below+ // maxEntries. A collapsed overflow row keeps it too, since a search+ // started while focused can settle after focus leaves.+ hasBusySlot={value.length > 0 && !isDisabled && !isAtMax}>{endContent}{hasClearButton && (<InputClearButtondiff --git a/packages/core/src/Tokenizer/__tests__/TokenizerEndLane.a11y.chromium.spec.ts b/packages/core/src/Tokenizer/__tests__/TokenizerEndLane.a11y.chromium.spec.tsnew file mode 100644index 0000000000..a3f597a470--- /dev/null+++ b/packages/core/src/Tokenizer/__tests__/TokenizerEndLane.a11y.chromium.spec.ts@@ -0,0 +1,471 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file TokenizerEndLane.a11y.chromium.spec.ts+ * @input `Core/Tokenizer` and `Core/PowerSearch` stories in a built Storybook.+ * @output Real-engine proof that tokens, the overflow count and the input's+ * text box never paint under the end lane (clear-all and busy indicator),+ * across field widths, both writing directions and both overflow modes.+ * @position Run with `pnpm test:a11y-contract`. The lane is absolutely+ * positioned, so whether a token reaches it depends on how rows wrap at a+ * given width, which only a shipping layout engine can show.+ */++import {expect, test, type Page} from '@playwright/test';+import {+ DEFAULT_STORYBOOK_DIR,+ serveStorybook,+ type StaticServer,+} from '@astryxdesign/a11y-spec/storybook';++let storybook: StaticServer;++test.beforeAll(async () => {+ storybook = await serveStorybook(+ process.env.ASTRYX_STORYBOOK_DIR ?? DEFAULT_STORYBOOK_DIR,+ );+});++test.afterAll(async () => {+ await storybook?.close();+});++type Direction = 'ltr' | 'rtl';++async function open(+ page: Page,+ id: string,+ direction: Direction,+ args = '',+): Promise<void> {+ await page.goto(+ `${storybook.origin}/iframe.html?id=${id}&viewMode=story&globals=direction:${direction}${args ? `&args=${args}` : ''}`,+ {waitUntil: 'load'},+ );+ await page+ .locator('button[aria-label="Clear all"]')+ .first()+ .waitFor({state: 'attached'});+ await page.evaluate(async () => {+ await document.fonts.ready;+ });+}++/**+ * Sets the story's sizing container to `width` and, for every field with a+ * visible clear-all lane, returns each visible box that intersects the lane:+ * tokens, the "+N more" count, and the input's content box (where its text+ * and caret paint).+ */+async function overlapsAt(page: Page, width: number): Promise<string[]> {+ return page.evaluate(async width => {+ // The story decorator's fixed-width box; the layer mode's popover takes+ // its width from the in-flow field inside it.+ const host = document.querySelector<HTMLElement>(+ '#storybook-root [style*="width"]',+ );+ if (!host) {+ throw new Error('No sizing container in the story');+ }+ host.style.width = `${width}px`;+ for (let frame = 0; frame < 4; frame++) {+ await new Promise(resolve => requestAnimationFrame(resolve));+ }++ const isShown = (el: Element) =>+ el.checkVisibility({visibilityProperty: true}) &&+ !el.closest('[aria-hidden="true"]');+ const lanes = [+ ...document.querySelectorAll('button[aria-label="Clear all"]'),+ ]+ .filter(isShown)+ .map(clear => clear.parentElement)+ .filter(lane => lane?.parentElement != null) as HTMLElement[];+ if (lanes.length === 0) {+ throw new Error('No clear-all lane is visible');+ }++ return lanes.flatMap((lane, fieldIndex) => {+ const field = lane.parentElement as HTMLElement;+ const boxes: {name: string; rect: DOMRect}[] = [];+ field.querySelectorAll('.astryx-token').forEach((token, index) => {+ if (isShown(token)) {+ boxes.push({+ name: `token ${index}`,+ rect: token.getBoundingClientRect(),+ });+ }+ });+ field.querySelectorAll('span').forEach(span => {+ if (/^\+\d+ more$/.test(span.textContent ?? '') && isShown(span)) {+ boxes.push({+ name: 'overflow count',+ rect: span.getBoundingClientRect(),+ });+ }+ });+ const input = field.querySelector<HTMLInputElement>('[role="combobox"]');+ if (input && isShown(input) && getComputedStyle(input).opacity !== '0') {+ const style = getComputedStyle(input);+ const rect = input.getBoundingClientRect();+ const left = rect.left + parseFloat(style.paddingLeft);+ const right = rect.right - parseFloat(style.paddingRight);+ if (right > left) {+ boxes.push({+ name: 'input text box',+ rect: new DOMRect(left, rect.top, right - left, rect.height),+ });+ }+ }++ const laneRect = lane.getBoundingClientRect();+ return boxes.flatMap(({name, rect}) => {+ const x =+ Math.min(rect.right, laneRect.right) -+ Math.max(rect.left, laneRect.left);+ const y =+ Math.min(rect.bottom, laneRect.bottom) -+ Math.max(rect.top, laneRect.top);+ return x > 0.5 && y > 0.5+ ? [+ `${width}px field ${fieldIndex}: ${name} overlaps the end lane by ${x.toFixed(1)}px`,+ ]+ : [];+ });+ });+ }, width);+}++async function sweep(page: Page, from: number, to: number): Promise<string[]> {+ const found: string[] = [];+ for (let width = from; width <= to; width += 4) {+ found.push(...(await overlapsAt(page, width)));+ }+ return found;+}++/**+ * The same sweep with a search in flight at every width. The busy Spinner joins+ * the lane only while a search runs, so each width is measured while the+ * combobox reports `aria-busy`, typing again whenever the last search settled.+ */+async function sweepWhileBusy(+ page: Page,+ from: number,+ to: number,+): Promise<string[]> {+ const search = page.getByRole('combobox');+ const found: string[] = [];+ for (let width = from; width <= to; width += 4) {+ for (;;) {+ if ((await search.getAttribute('aria-busy')) !== 'true') {+ await search.press('a');+ await expect(search).toHaveAttribute('aria-busy', 'true');+ }+ const overlaps = await overlapsAt(page, width);+ if ((await search.getAttribute('aria-busy')) === 'true') {+ found.push(...overlaps);+ break;+ }+ }+ }+ return found;+}++/**+ * Sizes the story container (a pixel width, or `max-content` for a+ * content-sized field) and returns the field's border box.+ */+async function fieldBoxAt(+ page: Page,+ width: string,+): Promise<{width: number; height: number}> {+ return page.evaluate(async width => {+ const host = document.querySelector<HTMLElement>(+ '#storybook-root [style*="width"]',+ );+ const field = document.querySelector('button[aria-label="Clear all"]')+ ?.parentElement?.parentElement;+ if (!host || !field) {+ throw new Error('Field or sizing container did not render');+ }+ host.style.width = width;+ for (let frame = 0; frame < 4; frame++) {+ await new Promise(resolve => requestAnimationFrame(resolve));+ }+ const {width: w, height: h} = field.getBoundingClientRect();+ return {+ width: Math.round(w * 100) / 100,+ height: Math.round(h * 100) / 100,+ };+ }, width);+}++/** Adds tokens through the menu, as a person would. */+async function addTokens(page: Page, names: string[]): Promise<void> {+ const search = page.getByRole('combobox');+ for (const name of names) {+ await search.fill(name.split(' ')[0]);+ await page.getByRole('option', {name}).click();+ await expect(search).not.toHaveAttribute('aria-busy', 'true');+ }+}++/**+ * The field's box with a search settled and again with one in flight. The+ * query is non-empty both times, so only the busy state differs.+ */+async function settledAndBusy(+ page: Page,+ width: string,+): Promise<string | null> {+ const search = page.getByRole('combobox');+ await search.fill('a');+ await expect(search).not.toHaveAttribute('aria-busy', 'true');+ const settled = await fieldBoxAt(page, width);+ await search.press('b');+ await expect(search).toHaveAttribute('aria-busy', 'true');+ const busy = await fieldBoxAt(page, width);+ const stillBusy = (await search.getAttribute('aria-busy')) === 'true';+ if (!stillBusy) {+ throw new Error(`The search settled before ${width} was measured`);+ }+ return settled.width === busy.width && settled.height === busy.height+ ? null+ : `${width}: settled ${settled.width}x${settled.height}, busy ${busy.width}x${busy.height}`;+}++/**+ * With four tokens on the Loading story, every width from 200px to 400px and a+ * content-sized container where the field's box differs settled vs busy.+ */+async function busyLayoutChanges(page: Page, step: number): Promise<string[]> {+ await addTokens(page, ['Bob Smith', 'Charlie Brown', 'Diana Prince']);+ await expect(page.locator('.astryx-token')).toHaveCount(4);+ const changed: string[] = [];+ for (let width = 200; width <= 400; width += step) {+ const change = await settledAndBusy(page, `${width}px`);+ if (change) {+ changed.push(change);+ }+ }+ // Content-sized: the field may not widen while busy (input-fields FR1).+ const contentSized = await settledAndBusy(page, 'max-content');+ if (contentSized) {+ changed.push(contentSized);+ }+ return changed;+}++/**+ * The blurred, collapsed field at `width`: its border box, how many tokens+ * show, and the "+N more" count.+ */+async function collapsedRowAt(page: Page, width: string): Promise<string> {+ const box = await fieldBoxAt(page, width);+ const row = await page.evaluate(() => {+ const field = document.querySelector('button[aria-label="Clear all"]')+ ?.parentElement?.parentElement;+ if (!field) {+ throw new Error('Field did not render');+ }+ const shown = [...field.querySelectorAll('.astryx-token')].filter(+ token =>+ token.checkVisibility({visibilityProperty: true}) &&+ !token.closest('[aria-hidden="true"]'),+ ).length;+ const count = [...field.querySelectorAll('span')].find(span =>+ /^\+\d+ more$/.test(span.textContent ?? ''),+ );+ return `${shown} tokens, ${count?.textContent ?? 'no count'}`;+ });+ return `${box.width}x${box.height}, ${row}`;+}++for (const direction of ['ltr', 'rtl'] as const) {+ test.describe(direction, () => {+ test('PowerSearch tokens (custom renderToken) wrap before the end lane', async ({+ page,+ }) => {+ await open(page, 'core-powersearch--near-full-token-row', direction);+ expect(await sweep(page, 160, 640)).toEqual([]);+ });++ test('a token wider than the row truncates short of the end lane', async ({+ page,+ }) => {+ await open(page, 'core-tokenizer--long-token-end-lane', direction);+ expect(await sweep(page, 160, 400)).toEqual([]);+ });++ test('default Tokenizer tokens wrap before the end lane', async ({+ page,+ }) => {+ await open(+ page,+ 'core-tokenizer--with-preselected',+ direction,+ 'hasClear:!true',+ );+ expect(await sweep(page, 160, 400)).toEqual([]);+ });++ test('tokens stay clear of the lane while a search is busy', async ({+ page,+ }) => {+ await open(page, 'core-tokenizer--loading', direction);+ await page.getByRole('combobox').focus();+ expect(await sweepWhileBusy(page, 200, 400)).toEqual([]);+ });++ test('a search starting does not move the field or its token rows', async ({+ page,+ }) => {+ test.setTimeout(240_000);+ await open(page, 'core-tokenizer--loading', direction);+ expect(await busyLayoutChanges(page, 4)).toEqual([]);+ });++ test('the reserved Spinner costs no frames and stays silent while idle', async ({+ page,+ }) => {+ await open(page, 'core-tokenizer--loading', direction);+ const search = page.getByRole('combobox');+ const cdp = await page.context().newCDPSession(page);+ await cdp.send('Performance.enable');+ // Style recalculations over a short window: a ticking ring animation+ // recalculates every frame (about 30 in 500ms), an unrendered one does+ // not. The idle allowance absorbs a stray one-off recalculation.+ const recalcsOver = async (ms: number) => {+ const count = async () => {+ const {metrics} = await cdp.send('Performance.getMetrics');+ return metrics.find(m => m.name === 'RecalcStyleCount')?.value ?? 0;+ };+ const before = await count();+ await page.waitForTimeout(ms);+ return (await count()) - before;+ };+ const spinnerState = async () =>+ page.evaluate(() => {+ const spinner = document+ .querySelector('button[aria-label="Clear all"]')+ ?.parentElement?.querySelector('.astryx-spinner');+ if (!spinner) {+ throw new Error('The lane holds no Spinner');+ }+ return {+ hidden: spinner.getAttribute('aria-hidden') === 'true',+ width: spinner.getBoundingClientRect().width,+ };+ });+ const idle = await spinnerState();+ expect(idle.hidden).toBe(true);+ expect(await recalcsOver(500)).toBeLessThanOrEqual(2);+ await search.focus();+ await search.press('a');+ await expect(search).toHaveAttribute('aria-busy', 'true');+ const busy = await spinnerState();+ expect(busy.hidden).toBe(false);+ expect(await recalcsOver(500)).toBeGreaterThanOrEqual(10);+ expect(busy.width).toBe(idle.width);+ });++ test('the idle Spinner paints nothing, even when a theme styles its box', async ({+ page,+ }) => {+ await page.goto(+ `${storybook.origin}/iframe.html?id=core-tokenizer--loading&viewMode=story&globals=direction:${direction};astryxTheme:probe`,+ {waitUntil: 'load'},+ );+ await page+ .locator('button[aria-label="Clear all"]')+ .waitFor({state: 'attached'});+ const search = page.getByRole('combobox');+ const spinnerPaint = async () =>+ page.evaluate(() => {+ const spinner = document+ .querySelector('button[aria-label="Clear all"]')+ ?.parentElement?.querySelector('.astryx-spinner');+ if (!spinner) {+ throw new Error('The lane holds no Spinner');+ }+ const style = getComputedStyle(spinner);+ return {+ visible: spinner.checkVisibility({visibilityProperty: true}),+ visibility: style.visibility,+ background: style.backgroundColor,+ };+ });+ const idle = await spinnerPaint();+ // The probe theme paints the Spinner's own box, so a box that is only+ // content-skipped would still show beside Clear all.+ expect(idle.background).not.toBe('rgba(0, 0, 0, 0)');+ expect(idle.visibility).toBe('hidden');+ expect(idle.visible).toBe(false);+ await search.focus();+ await search.press('a');+ await expect(search).toHaveAttribute('aria-busy', 'true');+ expect((await spinnerPaint()).visible).toBe(true);+ });++ test('a themed, larger Spinner keeps its space too', async ({page}) => {+ test.setTimeout(240_000);+ await open(page, 'core-tokenizer--loading', direction);+ // The public size var a theme sets for a named Spinner size.+ await page.addStyleTag({+ content: '.astryx-spinner { --spinner-diameter: 24px !important; }',+ });+ expect(await busyLayoutChanges(page, 8)).toEqual([]);+ });++ test('a search settling after blur does not change the collapsed row', async ({+ page,+ }) => {+ test.setTimeout(240_000);+ await open(+ page,+ 'core-tokenizer--loading',+ direction,+ 'tokenOverflowBehavior:unfocusedInline',+ );+ const search = page.getByRole('combobox');+ await search.focus();+ await addTokens(page, ['Bob Smith', 'Charlie Brown', 'Diana Prince']);+ const changed: string[] = [];+ for (let width = 200; width <= 400; width += 8) {+ await search.focus();+ await search.fill('');+ await search.press('a');+ await expect(search).toHaveAttribute('aria-busy', 'true');+ await search.blur();+ const busy = await collapsedRowAt(page, `${width}px`);+ await expect(search).not.toHaveAttribute('aria-busy', 'true');+ const settled = await collapsedRowAt(page, `${width}px`);+ if (busy !== settled) {+ changed.push(`${width}px: busy ${busy}, settled ${settled}`);+ }+ }+ expect(changed).toEqual([]);+ });++ for (const mode of ['overflow-inline', 'overflow-layer']) {+ test(`${mode}: blurred and focused tokens stay clear of the end lane`, async ({+ page,+ }) => {+ await open(page, `core-powersearch--${mode}`, direction);+ // Blurred: only the inline mode keeps its lane on the page.+ if (mode === 'overflow-inline') {+ expect(await sweep(page, 320, 640)).toEqual([]);+ }+ // The field's own corner, clear of every token: the click a person+ // makes to start typing, which expands both modes.+ await page+ .locator('.astryx-tokenizer')+ .first()+ .click({position: {x: 1, y: 1}});+ await expect(page.getByRole('combobox')).toBeFocused();+ expect(await sweep(page, 320, 640)).toEqual([]);+ });+ }+ });+}