An open source design system that's fully customizable and agent ready
TypeScript
fix(FieldLabel): labelTooltip is an InfoTip button after the label, reachable by keyboard and screen readers (#6414)
Guillaume M711acc68bd23
diff --git a/.changeset/fieldlabel-infotip.md b/.changeset/fieldlabel-infotip.mdnew file mode 100644index 0000000000..fa98b8e94b--- /dev/null+++ b/.changeset/fieldlabel-infotip.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] `FieldLabel`'s `labelTooltip` is now an info button after the label, named "About {label}", so keyboard and screen-reader users can reach the help (WCAG 2.2 2.1.1, 4.1.2), and a click or key press on it opens the help without focusing or toggling the field.++@GuillaumeMMM @cixzhangdiff --git a/apps/storybook/stories/FieldLabel.stories.tsx b/apps/storybook/stories/FieldLabel.stories.tsxindex cac2c17692..8866120296 100644--- a/apps/storybook/stories/FieldLabel.stories.tsx+++ b/apps/storybook/stories/FieldLabel.stories.tsx@@ -3,6 +3,12 @@import type {Meta, StoryObj} from '@storybook/react';import {FieldLabel} from '@astryxdesign/core/Field';import {Icon} from '@astryxdesign/core/Icon';+import {FormLayout} from '@astryxdesign/core/FormLayout';+import {TextInput} from '@astryxdesign/core/TextInput';+import {VStack} from '@astryxdesign/core/Stack';+import {Text} from '@astryxdesign/core/Text';+import {Dialog, DialogHeader} from '@astryxdesign/core/Dialog';+import {Layout, LayoutContent} from '@astryxdesign/core/Layout';const meta: Meta<typeof FieldLabel> = {title: 'Core/FieldLabel',@@ -23,6 +29,68 @@ const groupStyle = {* controls make label, group, hidden-label, and description semantics observable* without turning each prop into a permanent story.*/+/**+ * A hidden label's info button inside real fields, in a stacked layout and in+ * a horizontal-labels FormLayout. Tab to the button: it shows just above its+ * field.+ */+export const HiddenLabelInfo: Story = {+ render: () => (+ <VStack gap={6}>+ <Text type="body">Directory</Text>+ <TextInput+ label="Search people"+ value=""+ onChange={() => {}}+ isLabelHidden+ labelTooltip="Searches names and teams."+ placeholder="Search people"+ />+ <FormLayout direction="horizontal-labels">+ <TextInput+ label="Search teams"+ value=""+ onChange={() => {}}+ isLabelHidden+ labelTooltip="Searches team names."+ placeholder="Search teams"+ />+ </FormLayout>+ </VStack>+ ),+};++/**+ * A hidden label's info button on the first field of a dialog's scrolling+ * body. Tab to the button: it shows in flow above the field, inside the body.+ */+export const HiddenLabelInfoInDialog: Story = {+ render: () => (+ <Dialog isOpen onOpenChange={() => {}} maxHeight="50vh">+ <Layout+ header={<DialogHeader title="Files" onOpenChange={() => {}} />}+ content={+ <LayoutContent>+ <TextInput+ label="Search files"+ value=""+ onChange={() => {}}+ isLabelHidden+ labelTooltip="Searches file names only."+ placeholder="Search files"+ />+ {Array.from({length: 12}, (_, index) => (+ <Text type="body" as="p" display="block" key={index}>+ File {index + 1}+ </Text>+ ))}+ </LayoutContent>+ }+ />+ </Dialog>+ ),+};+export const States: Story = {render: () => (<div style={{display: 'grid', gap: 24, maxWidth: 480}}>diff --git a/docs/specs/components/Field/Field.spec.md b/docs/specs/components/Field/Field.spec.mdindex 46ff575a47..1386b75b0d 100644--- a/docs/specs/components/Field/Field.spec.md+++ b/docs/specs/components/Field/Field.spec.md@@ -170,7 +170,9 @@ spacing tokens."Input clear icon": {"target": "input-clear-icon"},"Optional/Required indicator": {"inherits": "field-label"},"Label tooltip trigger": {- "delegatesTo": {"owner": "component:Icon", "target": "icon"}+ "none": {+ "reason": "unsettled: the trigger is component:InfoTip's button, which has no public theming target yet; its info icon stays on Icon/icon through InfoTip"+ }},"Label tooltip surface": {"delegatesTo": {"owner": "component:Tooltip", "target": "tooltip"}@@ -178,7 +180,7 @@ spacing tokens.}```-The ordinary description remains stable consumer anatomy without a Field-owned target. A visible horizontal-label description delegates to `Text/text`; when `isLabelHidden` is true, the same content delegates to `VisuallyHidden` and exposes no painted target. The label tooltip splits its visible `Icon/icon` trigger from its layer-hosted `Tooltip/tooltip` surface.+The ordinary description remains stable consumer anatomy without a Field-owned target. A visible horizontal-label description delegates to `Text/text`; when `isLabelHidden` is true, the same content delegates to `VisuallyHidden` and exposes no painted target. The label tooltip splits its `component:InfoTip` trigger button, which has no public target yet, from its layer-hosted `Tooltip/tooltip` surface.## Family and system relationships@@ -209,8 +211,6 @@ The ordinary description remains stable consumer anatomy without a Field-owned t- **Attached default (FR9).** Field defaults `statusVariant` to `attached` forevery child, against `family:input-fields/FR8`; how to migrate the default isOQ1.-- **Label tooltip (FieldLabel FR8).** A `labelTooltip` is reachable only by- pointer, as `component:FieldLabel` FR8 records, against WCAG 2.2 SC 2.1.1.## Decision logdiff --git a/docs/specs/components/Field/FieldLabel.spec.md b/docs/specs/components/Field/FieldLabel.spec.mdindex 13769a5e57..ca6813520e 100644--- a/docs/specs/components/Field/FieldLabel.spec.md+++ b/docs/specs/components/Field/FieldLabel.spec.md@@ -38,15 +38,15 @@ system_specs: [spec:AST-020/FR1]## Contract at a glance-| Area | Contract |-| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| Public contract | `FieldLabel` renders a visible or visually hidden label group for one control or a caller-labelled group, with optional description, optionality indicator, icon, tooltip, label-element BaseProps, and label-element ref. |-| Behavior | Single-control mode uses a native label; group mode uses a labelled span. A description adds a wrapper div, while caller props and ref stay on the inner label element. Description clicks forward only to one associated control. |-| End-user impact | People can identify a control or group, hear supporting text separately from its name, and activate eligible controls from the complete visible label area. Help behind the info button opens by pointer, touch, keyboard, and screen reader, and a tap, click, or key press on it never changes the control (DEC-1); the shipped icon stays pointer-only, and a mouse click on it still activates the control, until FR9 is built. |-| Builder impact | Builders provide stable control and description IDs, select group mode when labelling a composite, and wire `aria-labelledby` or `aria-describedby` on the controlled surface. |-| Compatibility/readiness | No API or default change; with `labelTooltip`, the info trigger becomes an InfoTip button after the label element, and a mouse click on it stops activating the control (FR9, DEC-1; not yet built). Group mode renders a span while public types promise label props and ref, and the shipped tooltip icon exposes its content only to a pointer; both are listed under Current-state impact. |-| Review checks | Reject a lost native/group association, nested description in the accessible name, forwarded clicks from group or interactive description content, dropped label-element props/ref, hidden tooltip content, an info trigger inside the label element or one whose press activates the control, or undocumented public prop. |-| Governing rules | Established public interface; HTML label semantics; WCAG 2.2 SC 2.1.1, SC 4.1.2; `component:InfoTip`; `architecture:public-component-api/INV1,INV5–INV9,INV12`; `architecture:component-theming-surface/INV3–INV7`; `spec:AST-020/FR1`. |+| Area | Contract |+| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| Public contract | `FieldLabel` renders a visible or visually hidden label group for one control or a caller-labelled group, with optional description, optionality indicator, icon, tooltip, label-element BaseProps, and label-element ref. |+| Behavior | Single-control mode uses a native label; group mode uses a labelled span. A description adds a wrapper div, while caller props and ref stay on the inner label element. Description clicks forward only to one associated control. |+| End-user impact | People can identify a control or group, hear supporting text separately from its name, and activate eligible controls from the complete visible label area. Help behind the info button opens by pointer, touch, keyboard, and screen reader, and a tap, click, or key press on it never changes the control (DEC-1). |+| Builder impact | Builders provide stable control and description IDs, select group mode when labelling a composite, and wire `aria-labelledby` or `aria-describedby` on the controlled surface. |+| Compatibility/readiness | No API or default change; with `labelTooltip`, the info trigger is an InfoTip button after the label element, and a mouse click on it does not activate the control (FR9, DEC-1). Group mode renders a span while public types promise label props and ref; it is listed under Current-state impact. |+| Review checks | Reject a lost native/group association, nested description in the accessible name, forwarded clicks from group or interactive description content, dropped label-element props/ref, hidden tooltip content, an info trigger inside the label element or one whose press activates the control, or undocumented public prop. |+| Governing rules | Established public interface; HTML label semantics; WCAG 2.2 SC 2.1.1, SC 4.1.2; `component:InfoTip`; `architecture:public-component-api/INV1,INV5–INV9,INV12`; `architecture:component-theming-surface/INV3–INV7`; `spec:AST-020/FR1`. |This table is a review projection; the body below is authoritative.@@ -86,23 +86,23 @@ This table is a review projection; the body below is authoritative.| label visibility | visible; visually hidden | Keeps label and description accessible while removing their layout space when hidden. | Both label modes. | visible | `component:FieldLabel` | released | Boolean-constrained. || optionality marker | none; optional; required | Shows the localized exception to FormLayout's form-level optionality default. | Visible and hidden labels. | none | `component:FieldLabel` | released | When both booleans are true, optional wins visibly, unless FormLayout's default is optional, which suppresses it and shows required. || leading icon | absent; icon type; rendered node | Adds visual content before the label text. | Both label modes. | absent | `component:FieldLabel` | released | Rendered through the shared icon slot. |-| explanatory tooltip | absent; localized string | Adds a `component:InfoTip` after the label element; a tap, click, or key press on it opens or closes the tooltip without activating the control (FR9). | Both label modes. | absent | `component:FieldLabel` | released | The shipped anchor is pointer-only until FR9 is built (FR8 gap). |+| explanatory tooltip | absent; localized string | Adds a `component:InfoTip` after the label element; a tap, click, or key press on it opens or closes the tooltip without activating the control (FR9). | Both label modes. | absent | `component:FieldLabel` | released | — || supporting description | absent; rendered node with optional explicit ID | Keeps supporting content separate from the accessible name and available for description. | Both label modes. | absent | `component:FieldLabel` | released | Missing ID leaves association to the caller. || description activation | forwarding; non-forwarding | For one control, noninteractive description clicks mirror native-label activation. | Single mode only. | forwarding | `component:FieldLabel` | released | Group mode and interactive descendants do not forward. |## Behavioral and layout contract-| ID | Invariant | Basis |-| --- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |-| FR1 | Single-control mode renders `<label htmlFor={inputID}>`; group mode renders a non-label element with `labelID` for caller-owned `aria-labelledby`. | Established public interface; HTML and ARIA semantics |-| FR2 | Visible and hidden labels retain the label text; hidden label and description boxes remain in the accessibility tree and leave no layout slot. | Established public interface |-| FR3 | Descriptions remain siblings of the label so they do not enter the control's accessible name. Noninteractive description clicks forward to one eligible control; group labels and interactive descendants do not forward activation. | Established public interface; native label behavior |-| FR4 | FormLayout optionality suppresses the matching visible marker; without a form default, the requested marker is localized and shown. When both flags are true, optional wins, except inside a FormLayout whose default is optional, where the optional marker is suppressed and the required marker shows. | Established public interface and current tests |-| FR5 | Label icons, tooltip anchors, required/optional text, and description content preserve source order. The label element uses a horizontal flex row; the optional label/description wrapper uses block flow. With `labelTooltip`, one inline-flex row wraps the label element and the InfoTip that follows it (FR9). All component-owned spacing is logical or direction-neutral. | Established public interface and source observation |-| FR6 | Accepted data, ARIA, DOM, class, style, event, and `xstyle` inputs compose on the label element without replacing the component-owned target or association. When a description renders, the outer wrapper is layout-only and caller props stay on the inner label element; the `labelTooltip` row (FR9) is layout-only in the same way, so caller class, `xstyle`, and ref stay on the label element. | `architecture:public-component-api/INV5–INV7` |-| FR7 | The public ref and label-element props MUST describe the element FieldLabel renders in each mode; which root element and public type group mode uses is OQ1. Implementation gap: group mode renders a `<span>` while the public BaseProps and ref types are fixed to `HTMLLabelElement`. | `architecture:public-component-api/INV8,INV9`; current runtime/types |-| FR8 | The optional tooltip's explanatory content MUST be reachable by keyboard (WCAG 2.2 SC 2.1.1) and its trigger MUST have an accessible name and role (WCAG 2.2 SC 4.1.2); FR9's InfoTip button meets both. Implementation gap: the shipped trigger is an anonymous, nonfocusable info icon, so the content is pointer-only until FR9 is built. | WCAG 2.2 SC 2.1.1, SC 4.1.2; `spec:AST-020/FR1` |-| FR9 | With `labelTooltip`, FieldLabel renders `component:InfoTip` with that content after the label element and outside it, and wraps the label element and the InfoTip in one inline-flex row, as it wraps the label and description, so no button sits inside a `<label>`; caller class, `xstyle`, and ref stay on the label element, and the row renders only when `labelTooltip` is set. With `isLabelHidden`, the InfoTip is visually hidden with the label, leaves no layout slot (FR2), and becomes visible while it has keyboard focus (WCAG 2.4.7); the button's name is a localized string that includes the label text ("About Auto-save"). A tap, click, Enter, or Space on the info trigger opens or closes the tooltip (`component:Tooltip` FR9) and never activates, focuses, or toggles the associated control; hover and focus preview it. Implementation gap: the shipped icon sits inside the label element; a tap by finger or pen opens or closes the tooltip without activating the control, but a mouse click on it also activates the control (Current-state impact). | DEC-1; HTML label content model; WCAG 2.2 SC 2.1.1, SC 2.4.7, SC 4.1.2 |+| ID | Invariant | Basis |+| --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------- |+| FR1 | Single-control mode renders `<label htmlFor={inputID}>`; group mode renders a non-label element with `labelID` for caller-owned `aria-labelledby`. | Established public interface; HTML and ARIA semantics |+| FR2 | Visible and hidden labels retain the label text; hidden label and description boxes remain in the accessibility tree and leave no layout slot. | Established public interface |+| FR3 | Descriptions remain siblings of the label so they do not enter the control's accessible name. Noninteractive description clicks forward to one eligible control; group labels and interactive descendants do not forward activation. | Established public interface; native label behavior |+| FR4 | FormLayout optionality suppresses the matching visible marker; without a form default, the requested marker is localized and shown. When both flags are true, optional wins, except inside a FormLayout whose default is optional, where the optional marker is suppressed and the required marker shows. | Established public interface and current tests |+| FR5 | Label icons, tooltip anchors, required/optional text, and description content preserve source order. The label element uses a horizontal flex row; the optional label/description wrapper uses block flow. With `labelTooltip`, one inline-flex row wraps the label element and the InfoTip that follows it (FR9). All component-owned spacing is logical or direction-neutral. | Established public interface and source observation |+| FR6 | Accepted data, ARIA, DOM, class, style, event, and `xstyle` inputs compose on the label element without replacing the component-owned target or association. When a description renders, the outer wrapper is layout-only and caller props stay on the inner label element; the `labelTooltip` row (FR9) is layout-only in the same way, so caller class, `xstyle`, and ref stay on the label element. | `architecture:public-component-api/INV5–INV7` |+| FR7 | The public ref and label-element props MUST describe the element FieldLabel renders in each mode; which root element and public type group mode uses is OQ1. Implementation gap: group mode renders a `<span>` while the public BaseProps and ref types are fixed to `HTMLLabelElement`. | `architecture:public-component-api/INV8,INV9`; current runtime/types |+| FR8 | The optional tooltip's explanatory content MUST be reachable by keyboard (WCAG 2.2 SC 2.1.1) and its trigger MUST have an accessible name and role (WCAG 2.2 SC 4.1.2); FR9's InfoTip button meets both. | WCAG 2.2 SC 2.1.1, SC 4.1.2; `spec:AST-020/FR1` |+| FR9 | With `labelTooltip`, FieldLabel renders `component:InfoTip` with that content after the label element and outside it, and wraps the label element and the InfoTip in one inline-flex row, as it wraps the label and description, so no button sits inside a `<label>`; caller class, `xstyle`, and ref stay on the label element, and the row renders only when `labelTooltip` is set. With `isLabelHidden`, the InfoTip is visually hidden with the label, leaves no layout slot (FR2), and while it has keyboard focus, the button takes its place in flow above the control (or in the label cell with horizontal labels), so it is never covered or clipped (WCAG 2.4.7, 2.4.11); the button's name is a localized string that includes the label text ("About Auto-save"). A tap, click, Enter, or Space on the info trigger opens or closes the tooltip (`component:Tooltip` FR9) and never activates, focuses, or toggles the associated control; hover and focus preview it. | DEC-1; HTML label content model; WCAG 2.2 SC 2.1.1, SC 2.4.7, SC 4.1.2 |### Allowed variation@@ -112,14 +112,14 @@ This table is a review projection; the body below is authoritative.### Representative states-| State | Required invariant | Allowed variation |-| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |-| single label | Native label association reaches the one control. | Visible or visually hidden. |-| group label | Label element is not a literal label and is referenceable by `labelID`. | Caller owns group role and `aria-labelledby`. |-| description | Supporting content remains outside the label and may expose `descriptionID`. | Text or structured content. |-| optional or required | One localized exception marker follows label text. | Suppressed when it matches FormLayout's default. |-| disabled presentation | Label uses disabled text treatment and no pointer cursor. | Associated control owns actual disabled state. |-| icon and tooltip | Shared Icon and InfoTip render their owned paint; the InfoTip button follows the label element, is keyboard-reachable and named, and its press never reaches the control (FR8, FR9). Implementation gap: the shipped anchor is nonfocusable, unnamed, and inside the label. | Either slot may be absent. |+| State | Required invariant | Allowed variation |+| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------ |+| single label | Native label association reaches the one control. | Visible or visually hidden. |+| group label | Label element is not a literal label and is referenceable by `labelID`. | Caller owns group role and `aria-labelledby`. |+| description | Supporting content remains outside the label and may expose `descriptionID`. | Text or structured content. |+| optional or required | One localized exception marker follows label text. | Suppressed when it matches FormLayout's default. |+| disabled presentation | Label uses disabled text treatment and no pointer cursor. | Associated control owns actual disabled state. |+| icon and tooltip | Shared Icon and InfoTip render their owned paint; the InfoTip button follows the label element, is keyboard-reachable and named, and its press never reaches the control (FR8, FR9). | Either slot may be absent. |### Transformation and precedence order@@ -138,8 +138,7 @@ This table is a review projection; the body below is authoritative.- **AR4 — Activation boundary.** Description activation never hijacks interactive descendants and never forwards from a group label to one control.- **AR5 — Tooltip reachability.** Tooltip content MUST be reachable by keyboard(WCAG 2.2 SC 2.1.1) through a named trigger (SC 4.1.2), the InfoTip button- that follows the label (FR8, FR9). Implementation gap: until FR9 is built,- the anonymous, nonfocusable anchor exposes it only to a pointer.+ that follows the label (FR8, FR9).## Design relationships@@ -153,30 +152,24 @@ No current repository design record governs component-local visual tuning. The i## Verification map-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |-| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------- |-| FR1–FR3, AR1–AR4 | `FieldLabel.test.tsx` association, ref, and description-forwarding cases; `FieldLabelAudit.a11y.chromium.spec.ts` default, custom-theme, RTL, and narrow cases in light and dark | Single, group, description, interactive description child | A wrong label element, lost association, nested description, or forwarded group or interactive click fails. Evidence gap: no test asserts the hidden label and description leave no layout slot. | `audit:FieldLabel/accessibility` |-| FR4, ORD1 | `FieldLabel.test.tsx` optional, required, both-set, and i18n cases; `FormLayout.test.tsx` default-optionality cases through Field | Optional, required, both, localized | A wrong localized marker, required winning over optional, or a marker that restates the form default fails. | `audit:FieldLabel/behavior` |-| FR5 | `FieldLabel.test.tsx` label-icon, tooltip, and tooltip-with-optional cases | Icon, tooltip, optionality | A missing icon or tooltip anchor fails. Evidence gap: no test asserts source order, the flex row, or logical spacing; and, until FR9 is built, the `labelTooltip` row with the InfoTip after the label element. | `audit:FieldLabel/layout` |-| FR6, ORD2 | `FieldLabel.test.tsx` ref, layout-item, and label-target cases; `themingTargets.test.ts` | Ref; composed target; with a description wrapper | A dropped ref or a lost `field-label` target fails; a rendered class absent from the documented targets fails. Evidence gap: no test asserts caller class, style, `xstyle`, data, and event props on the inner label element with a description wrapper, or, until FR9 is built, with the `labelTooltip` row. | `audit:FieldLabel/api` |-| FR7 | Evidence gap: no type test pins the public ref and props against the rendered group span | — | — | `audit:FieldLabel/api` |-| FR8, AR5 | `FieldLabelAudit.a11y.chromium.spec.ts` tooltip-anchor count | Tooltip present | The audit records the one anonymous, nonfocusable anchor; once FR9 is built it asserts one named InfoTip button outside the label element. | `audit:FieldLabel/accessibility` |-| FR9 | `FieldLabel.test.tsx` finger-tap, pen-tap, and mouse-click checkbox cases; `FieldLabelTap.a11y.chromium.spec.ts` touch-tap and mouse-click text-field cases; evidence gap until built: Enter and Space on the InfoTip button, the button's place outside the label, and the hidden-label cases | Checkbox, text field, and Switch labels; finger, pen, mouse, Enter, and Space; `isLabelHidden` with keyboard focus on the InfoTip | A tap that toggles or focuses the control fails today. Until FR9 is built the mouse-click cases assert the shipped activation; once built, a click or key press on the info trigger that activates, focuses, or toggles the control, an info button inside the label element, a trigger without the label in its name, or a hidden label's InfoTip that takes layout space or stays invisible while focused fails. | `audit:FieldLabel/accessibility` |-| PR1 | Evidence gap: no test asserts the absence of retained resources | — | — | `audit:FieldLabel/code-health` |-| Documentation | `docPropLiterals.test.ts`; `docPropReferences.test.ts` | Documented props and defaults | A documented literal or prop reference that drifts from the source type fails. | `audit:FieldLabel/docs` |-| RTL applicability | `apps/storybook/rtl-audit/verified-not-applicable.json` entry for `core/FieldLabel` | Checked-in FieldLabel stories | A story that gains directional placement or behavior makes the not-applicable entry stale. | `audit:FieldLabel/i18n-rtl` |+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |+| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |+| FR1–FR3, AR1–AR4 | `FieldLabel.test.tsx` association, ref, and description-forwarding cases; `FieldLabelAudit.a11y.chromium.spec.ts` default, custom-theme, RTL, and narrow cases in light and dark | Single, group, description, interactive description child | A wrong label element, lost association, nested description, or forwarded group or interactive click fails. Evidence gap: no test asserts the hidden label and description leave no layout slot. | `audit:FieldLabel/accessibility` |+| FR4, ORD1 | `FieldLabel.test.tsx` optional, required, both-set, and i18n cases; `FormLayout.test.tsx` default-optionality cases through Field | Optional, required, both, localized | A wrong localized marker, required winning over optional, or a marker that restates the form default fails. | `audit:FieldLabel/behavior` |+| FR5 | `FieldLabel.test.tsx` label-icon, info-button placement, and tooltip-with-optional cases | Icon, tooltip, optionality | A missing icon or tooltip anchor fails. Evidence gap: no test asserts source order, the flex row, or logical spacing. | `audit:FieldLabel/layout` |+| FR6, ORD2 | `FieldLabel.test.tsx` ref, layout-item, and label-target cases; `themingTargets.test.ts` | Ref; composed target; with a description wrapper | A dropped ref or a lost `field-label` target fails; a rendered class absent from the documented targets fails. Evidence gap: no test asserts caller class, style, `xstyle`, data, and event props on the inner label element with a description wrapper or with the `labelTooltip` row. | `audit:FieldLabel/api` |+| FR7 | Evidence gap: no type test pins the public ref and props against the rendered group span | — | — | `audit:FieldLabel/api` |+| FR8, AR5 | `FieldLabelAudit.a11y.chromium.spec.ts` tooltip-anchor count | Tooltip present | The audit asserts one named, focusable InfoTip button after the label element and outside it; an anonymous, unfocusable, or label-nested trigger fails. | `audit:FieldLabel/accessibility` |+| FR9 | `FieldLabel.test.tsx` info-button placement and name, hidden-label tab stop, finger-tap, pen-tap, mouse-click, and Space checkbox cases and the Switch-label click case; `FieldLabelTap.a11y.chromium.spec.ts` touch-tap, mouse-click, and Enter text-field cases and the hidden label's focused button on top of the field; evidence gap: no check measures that the hidden label's button takes no layout slot | Checkbox, text field, and Switch labels; finger, pen, mouse, Enter, and Space; `isLabelHidden` with keyboard focus on the InfoTip | A tap, click, or key press on the info trigger that activates, focuses, or toggles the control, an info button inside the label element, a trigger without the label in its name, or a hidden label's InfoTip that takes layout space or stays invisible while focused fails. | `audit:FieldLabel/accessibility` |+| PR1 | Evidence gap: no test asserts the absence of retained resources | — | — | `audit:FieldLabel/code-health` |+| Documentation | `docPropLiterals.test.ts`; `docPropReferences.test.ts` | Documented props and defaults | A documented literal or prop reference that drifts from the source type fails. | `audit:FieldLabel/docs` |+| RTL applicability | `apps/storybook/rtl-audit/verified-not-applicable.json` entry for `core/FieldLabel` | Checked-in FieldLabel stories | A story that gains directional placement or behavior makes the not-applicable entry stale. | `audit:FieldLabel/i18n-rtl` |## Current-state impact- **Group-mode typing (FR7).** Group mode renders a `<span>` while the publicprops and ref are typed for `HTMLLabelElement`, against`architecture:public-component-api` INV8 and INV9; the fix is OQ1.-- **Tooltip reachability (FR8, AR5).** The label tooltip is pointer-only,- against WCAG 2.2 SC 2.1.1 and 4.1.2, until FR9's InfoTip is built.-- **A mouse click on the info icon activates the control (FR9).** The shipped- icon sits inside the label element; a finger or pen tap opens its help- without activating the control, but a mouse click on it also focuses or- toggles the control.## Decision logdiff --git a/packages/core/locales/en.json b/packages/core/locales/en.jsonindex 61c99fd4bb..ad9df0def4 100644--- a/packages/core/locales/en.json+++ b/packages/core/locales/en.json@@ -1431,6 +1431,10 @@"defaultMessage": "Optional","description": "Visible indicator shown next to a form field's label when the field is optional (isOptional). Mutually exclusive with the required indicator. Very short — appears inline after the label text."},+ "@astryx.field.labelTooltip": {+ "defaultMessage": "About {label}",+ "description": "Screen-reader name of the small info button after a form field's label; the button shows help about the field. {label} is the field's visible label. Example: `About Auto-save`."+ },"@astryx.field.required": {"defaultMessage": "Required","description": "Visible indicator shown next to a form field's label when the field must be filled in (isRequired). Mutually exclusive with the optional indicator. Very short — appears inline after the label text."diff --git a/packages/core/src/Field/Field.doc.mjs b/packages/core/src/Field/Field.doc.mjsindex 741a2864c6..ad2e0b0008 100644--- a/packages/core/src/Field/Field.doc.mjs+++ b/packages/core/src/Field/Field.doc.mjs@@ -121,7 +121,7 @@ export const docs = {name: 'labelTooltip',type: 'string',description:- 'Tooltip text to display in an info icon at the end of the label. Hover shows it; on a touch screen a tap on the icon opens it without focusing the field, while a mouse click on the icon focuses the field like the rest of the label.',+ 'Help text for an info button after the label, named "About {label}". Hover and keyboard focus preview it; a tap, click, Enter, or Space opens it and never focuses or toggles the control.',},{name: 'status',diff --git a/packages/core/src/Field/Field.test.tsx b/packages/core/src/Field/Field.test.tsxindex cdac1a12e8..01d34b3af0 100644--- a/packages/core/src/Field/Field.test.tsx+++ b/packages/core/src/Field/Field.test.tsx@@ -273,8 +273,9 @@ describe('Field', () => {<input id="help-input" /></Field>,);- // Info icon should be present- expect(document.querySelector('svg')).toBeInTheDocument();+ expect(+ screen.getByRole('button', {name: 'About Help'}),+ ).toBeInTheDocument();});it('does not render tooltip icon when labelTooltip is not provided', () => {diff --git a/packages/core/src/Field/Field.tsx b/packages/core/src/Field/Field.tsxindex 842222cada..23bcb0d562 100644--- a/packages/core/src/Field/Field.tsx+++ b/packages/core/src/Field/Field.tsx@@ -177,7 +177,7 @@ export interface FieldProps extends Omit<*/status?: FieldStatusInput;/**- * Tooltip text to display in an info icon at the end of the label.+ * Help text for an info button after the label, named "About {label}".*/labelTooltip?: string;/**diff --git a/packages/core/src/Field/FieldLabel.doc.mjs b/packages/core/src/Field/FieldLabel.doc.mjsindex def017bf56..f9c9359192 100644--- a/packages/core/src/Field/FieldLabel.doc.mjs+++ b/packages/core/src/Field/FieldLabel.doc.mjs@@ -73,7 +73,7 @@ export const docs = {name: 'labelTooltip',type: 'string',description:- 'Tooltip text for the info icon after the label. Hover shows it; on a touch screen a tap on the icon opens it without focusing the field or toggling the control, while a mouse click on the icon activates the control like the rest of the label.',+ 'Help text for an info button after the label, named "About {label}". Hover and keyboard focus preview it; a tap, click, Enter, or Space opens it and never focuses or toggles the control.',},{name: 'description',@@ -229,7 +229,7 @@ export const docsDense = {isOptional: 'Show localized optional exception indicator.',isRequired: 'Show localized required exception indicator.',labelIcon: 'Icon type or rendered icon content before label text.',- labelTooltip: 'Tooltip text for the info icon after the label.',+ labelTooltip: 'Help text for the info button after the label.',description: 'Supporting content outside the accessible name.',descriptionID: 'ID for caller-owned aria-describedby wiring.',ref: 'Ref forwarded to the label element; group mode renders a span.',diff --git a/packages/core/src/Field/FieldLabel.test.tsx b/packages/core/src/Field/FieldLabel.test.tsxindex e5ce6f7754..d28bbade9b 100644--- a/packages/core/src/Field/FieldLabel.test.tsx+++ b/packages/core/src/Field/FieldLabel.test.tsx@@ -15,6 +15,7 @@ import userEvent from '@testing-library/user-event';import {TestIcon} from '../__tests__/TestIcon';import {InternationalizationProvider} from '../i18n';import {FieldLabel} from './FieldLabel';+import {Switch} from '../Switch/Switch';import {themeProps} from '../utils/themeProps';import {__resetInteractionModalityForTest} from '../utils/interactionModality';@@ -105,17 +106,43 @@ describe('FieldLabel', () => {expect(container.firstElementChild).toBe(label);});- it('renders tooltip info icon when labelTooltip prop is provided', () => {+ it('renders an info button named after the label, after the label element and outside it', () => {render(- <FieldLabel- label="Help"- inputID="help-input"- labelTooltip="This is helpful information"- />,+ <>+ <FieldLabel+ label="Help"+ inputID="help-input"+ labelTooltip="This is helpful information"+ />+ <input id="help-input" type="text" />+ </>,+ );+ const button = screen.getByRole('button', {name: 'About Help'});+ const label = screen.getByText('Help').closest('label');+ // No button inside a label: a press on it would also activate the control.+ expect(button.closest('label')).toBeNull();+ expect(label?.nextElementSibling).toBe(button);+ expect(button).toHaveAccessibleDescription('This is helpful information');+ // The field's name stays the label alone.+ expect(screen.getByRole('textbox')).toHaveAccessibleName('Help');+ });++ it('keeps a hidden label’s info button reachable by keyboard', () => {+ render(+ <>+ <FieldLabel+ label="Search"+ inputID="search-input"+ isLabelHidden+ labelTooltip="Searches titles only"+ />+ <input id="search-input" type="text" />+ </>,+ );+ expect(screen.getByRole('button', {name: 'About Search'})).toHaveProperty(+ 'tabIndex',+ 0,);- // Two SVGs: the info icon is wrapped in tooltip- const svgs = document.querySelectorAll('svg');- expect(svgs.length).toBeGreaterThan(0);});it('does not render extra icon when labelTooltip is not provided', () => {@@ -134,8 +161,9 @@ describe('FieldLabel', () => {/>,);expect(screen.getByText(/Optional/)).toBeInTheDocument();- // Info icon should be present- expect(document.querySelector('svg')).toBeInTheDocument();+ expect(+ screen.getByRole('button', {name: 'About Field'}),+ ).toBeInTheDocument();});describe('labelTooltip under each pointer', () => {@@ -176,12 +204,9 @@ describe('FieldLabel', () => {fireEvent.click(element);};- /** The info icon the help tooltip is attached to, inside the label. */+ /** The info button after the label. */const infoIcon = (labelText: string) =>- screen- .getByText(labelText)- .closest('label')- ?.querySelector('[aria-describedby]') as HTMLElement;+ screen.getByRole('button', {name: `About ${labelText}`});it('opens the help on a tap of its icon and leaves a checkbox alone', async () => {render(@@ -228,7 +253,46 @@ describe('FieldLabel', () => {expect(screen.getByRole('checkbox')).not.toBeChecked();});- it('leaves a mouse click on its icon to the label, which toggles a checkbox', () => {+ it('opens the help on Space on its button and leaves a checkbox alone', async () => {+ const user = userEvent.setup();+ render(+ <>+ <FieldLabel+ label="Digest"+ inputID="digest"+ labelTooltip="One email a week"+ />+ <input type="checkbox" id="digest" />+ </>,+ );++ infoIcon('Digest').focus();+ await user.keyboard(' ');++ await waitFor(() => {+ expect(infoIcon('Digest')).toHaveAttribute('aria-expanded', 'true');+ });+ expect(screen.getByRole('checkbox')).not.toBeChecked();+ });++ it('leaves a Switch alone when its label’s info button is clicked', async () => {+ const user = userEvent.setup();+ const onChange = vi.fn();+ render(+ <Switch+ label="Auto-save"+ labelTooltip="Saves each change"+ value={false}+ onChange={onChange}+ />,+ );++ await user.click(infoIcon('Auto-save'));++ expect(onChange).not.toHaveBeenCalled();+ });++ it('opens the help on a mouse click of its button and leaves a checkbox alone', async () => {render(<><FieldLabel@@ -245,9 +309,13 @@ describe('FieldLabel', () => {fireEvent.pointerUp(icon, {pointerType: 'mouse'});fireEvent.click(icon);- // A mouse click anywhere on a native label, its info icon included,- // activates the label's control.- expect(screen.getByRole('checkbox')).toBeChecked();+ await waitFor(() => {+ expect(screen.getByRole('tooltip', {hidden: true})).toHaveAttribute(+ 'popover-open',+ );+ });+ // The button sits outside the label, so a click is for its help only.+ expect(screen.getByRole('checkbox')).not.toBeChecked();});});diff --git a/packages/core/src/Field/FieldLabel.tsx b/packages/core/src/Field/FieldLabel.tsxindex 88db96a91d..a5ad017b5d 100644--- a/packages/core/src/Field/FieldLabel.tsx+++ b/packages/core/src/Field/FieldLabel.tsx@@ -4,7 +4,7 @@/*** @file FieldLabel.tsx- * @input Uses React, Icon, IconType, useComponentTranslator, FormLayoutContext+ * @input Uses React, Icon, IconType, InfoTip, useComponentTranslator, FormLayoutContext* @output Exports FieldLabel component, FieldLabelProps* @position Core label implementation; used by Field, CheckboxInput, Switch*@@ -13,7 +13,7 @@* - /packages/core/src/Field/index.ts (exports if types change)* - /packages/core/src/FormLayout/FormLayoutContext.ts (defaultOptionality drives the indicator)* - /packages/cli/assets/templates/blocks/components/Field/ (showcase blocks)- * - /packages/core/locales/en.json (@astryx.field.required / @astryx.field.optional)+ * - /packages/core/locales/en.json (@astryx.field.required / @astryx.field.optional / @astryx.field.labelTooltip)*/import {use, useMemo, useRef, type ReactNode, type RefObject} from 'react';@@ -28,10 +28,9 @@ import {typographyVars,typeScaleVars,} from '../theme/tokens.stylex';-import {Icon, renderIconSlot} from '../Icon/Icon';+import {renderIconSlot} from '../Icon/Icon';import type {IconType} from '../Icon';-import {Tooltip} from '../Tooltip/Tooltip';-import {useTapStop} from '../Layer/useTouchTrigger';+import {InfoTip} from '../InfoTip/InfoTip';import {themeProps} from '../utils/themeProps';import {useInputContainer} from '../hooks/useInputContainer';import {FormLayoutContext} from '../FormLayout/FormLayoutContext';@@ -78,6 +77,31 @@ const styles = stylex.create({color: colorVars['--color-text-disabled'],cursor: 'default',},+ // A button inside a label also activates the label's control, so the info+ // button sits outside it, in one row with the label.+ labelRow: {+ display: 'inline-flex',+ alignItems: 'center',+ // In a block label cell, keep the row's top on the cell's top, not on a+ // text baseline.+ verticalAlign: 'top',+ gap: spacingVars['--spacing-1'],+ },+ // With a hidden label the row takes no slot in the caller's layout.+ labelRowHidden: {+ display: 'contents',+ },+ // A hidden label's info button takes no layout slot. While it has keyboard+ // focus, it moves into flow above the control. There nothing covers or clips+ // it. It stays positioned, because InfoTip's touch band needs a positioned+ // host.+ infoTipHidden: {+ position: {default: 'absolute', ':focus-visible': 'relative'},+ alignSelf: 'flex-start',+ clip: {default: 'rect(0, 0, 0, 0)', ':focus-visible': 'auto'},+ overflow: {default: 'hidden', ':focus-visible': 'visible'},+ whiteSpace: 'nowrap',+ },srOnly: {borderStyle: 'none',clip: 'rect(0, 0, 0, 0)',@@ -173,7 +197,7 @@ export interface FieldLabelProps extends BaseProps<HTMLLabelElement> {*/labelIcon?: ReactNode | IconType;/**- * Tooltip text to display in an info icon at the end of the label.+ * Help text for an info button after the label, named "About {label}".*/labelTooltip?: string;/**@@ -263,12 +287,6 @@ export function FieldLabel({// a ref-shaped object, since FieldLabel points at the control by id rather// than holding a ref to it.const descriptionRef = useRef<HTMLSpanElement>(null);- // A tap on the info icon asks for the help, so it stops there: it does not- // go on to activate the label's control, as a press anywhere else on the- // label would (focus the field, toggle a switch). A mouse click on the icon- // keeps that native activation, and hover shows the help.- const {onPointerDown: handleIconPointerDown, onClick: handleIconClick} =- useTapStop('click');const controlRef = useMemo<RefObject<HTMLElement | null>>(() => ({get current() {@@ -297,20 +315,6 @@ export function FieldLabel({{statusText}</span>)}- {labelTooltip && (- // The icon's one job is to reveal the help, so a tap on it opens or- // closes the help (`touchTrigger="tap"`), although it sits inside a- // `<label>`.- <Tooltip content={labelTooltip} placement="above" touchTrigger="tap">- <Icon- icon="info"- size="sm"- color="inherit"- onPointerDown={handleIconPointerDown}- onClick={handleIconClick}- />- </Tooltip>- )}</>);@@ -344,10 +348,27 @@ export function FieldLabel({</LabelElement>);+ const labelWithHelp = labelTooltip ? (+ <span+ {...stylex.props(+ styles.labelRow,+ isLabelHidden && styles.labelRowHidden,+ )}>+ {labelElement}+ <InfoTip+ content={labelTooltip}+ label={t('@astryx.field.labelTooltip', {label})}+ xstyle={isLabelHidden ? styles.infoTipHidden : undefined}+ />+ </span>+ ) : (+ labelElement+ );+// Without a description, preserve the original public DOM: the label itself// remains the caller's flex/grid item and its layout overrides apply there.if (!description) {- return labelElement;+ return labelWithHelp;}return (@@ -356,7 +377,7 @@ export function FieldLabel({styles.labelGroup,isLabelHidden && styles.labelGroupHidden,)}>- {labelElement}+ {labelWithHelp}<spanref={forwardsDescriptionClick ? descriptionRef : undefined}id={descriptionID}diff --git a/packages/core/src/Field/__tests__/FieldLabelAudit.a11y.chromium.spec.ts b/packages/core/src/Field/__tests__/FieldLabelAudit.a11y.chromium.spec.tsindex 11bbade5cd..c6655dd64c 100644--- a/packages/core/src/Field/__tests__/FieldLabelAudit.a11y.chromium.spec.ts+++ b/packages/core/src/Field/__tests__/FieldLabelAudit.a11y.chromium.spec.ts@@ -144,7 +144,7 @@ for (const item of cases) {await expect(page.getByText(/Optional/)).toBeVisible();await expect(page.getByLabel('Search')).toBeVisible();const tooltipAnchor = page- .locator('label[for="field-label-optional"] [aria-describedby]')+ .locator('label[for="field-label-optional"] + button').first();await expect(tooltipAnchor).toHaveCount(1);@@ -172,7 +172,7 @@ for (const item of cases) {'.astryx-field-label',);const currentTooltipAnchor = document.querySelector<HTMLElement>(- 'label[for="field-label-optional"] [aria-describedby]',+ 'label[for="field-label-optional"] + button',);return {theme: document@@ -191,11 +191,12 @@ for (const item of cases) {: null,tooltipAnchor: currentTooltipAnchor? {- ariaHidden: currentTooltipAnchor.getAttribute('aria-hidden'),+ tagName: currentTooltipAnchor.tagName,ariaLabel: currentTooltipAnchor.getAttribute('aria-label'),describedBy:currentTooltipAnchor.getAttribute('aria-describedby'),- tabIndex: currentTooltipAnchor.getAttribute('tabindex'),+ tabIndex: currentTooltipAnchor.tabIndex,+ isInsideLabel: currentTooltipAnchor.closest('label') != null,}: null,};@@ -207,10 +208,11 @@ for (const item of cases) {observed.labels.every(label => label.geometry.width > 0) &&observed.hiddenGeometry?.width === 1 &&observed.hiddenGeometry.height === 1;- const knownTooltipGapObserved =- observed.tooltipAnchor?.ariaHidden === 'true' &&- observed.tooltipAnchor.ariaLabel == null &&- observed.tooltipAnchor.tabIndex == null;+ const infoButtonPass =+ observed.tooltipAnchor?.tagName === 'BUTTON' &&+ observed.tooltipAnchor.ariaLabel?.startsWith('About ') === true &&+ observed.tooltipAnchor.tabIndex === 0 &&+ !observed.tooltipAnchor.isInsideLabel;const png = await page.screenshot({animations: 'disabled', fullPage: true});const image = `${item.key}.png`;@@ -226,8 +228,8 @@ for (const item of cases) {targetCount: 7,groupLabelTag: 'SPAN',hiddenGeometry: {width: 1, height: 1},- knownGap:- 'the tooltip anchor is anonymous and nonfocusable on this audited head',+ infoButton:+ 'one named, focusable info button after the label element and outside it',},observed: {build: storybookSha,@@ -240,7 +242,7 @@ for (const item of cases) {width: png.readUInt32BE(16),height: png.readUInt32BE(20),},- checks: {semanticsPass, knownTooltipGapObserved},+ checks: {semanticsPass, infoButtonPass},passed:storybookSha === checkoutSha &&pageErrors.length === 0 &&@@ -252,7 +254,8 @@ for (const item of cases) {observed.reducedMotion &&!observed.horizontalOverflow &&observed.fonts === 'loaded' &&- semanticsPass,+ semanticsPass &&+ infoButtonPass,};fs.writeFileSync(path.join(OUTPUT, image), png);fs.writeFileSync(diff --git a/packages/core/src/Field/__tests__/FieldLabelTap.a11y.chromium.spec.ts b/packages/core/src/Field/__tests__/FieldLabelTap.a11y.chromium.spec.tsindex 25744a69da..6692ac16c2 100644--- a/packages/core/src/Field/__tests__/FieldLabelTap.a11y.chromium.spec.ts+++ b/packages/core/src/Field/__tests__/FieldLabelTap.a11y.chromium.spec.ts@@ -3,10 +3,10 @@/*** @file FieldLabelTap.a11y.chromium.spec.ts* @input The `Core/FieldLabel` States story in a built Storybook, in Chromium:- * the Nickname field, whose label carries a `labelTooltip` info icon.- * @output Real-browser proof of FieldLabel FR9: a touch tap on the info icon- * shows its help and leaves the text field unfocused, while a mouse click on- * the icon focuses the field like a click anywhere else on the label.+ * the Nickname field, whose label has a `labelTooltip` info button after it.+ * @output Real-browser proof of FieldLabel FR9: a touch tap, a mouse click, and+ * Enter on the info button show its help and leave the text field+ * unfocused.* @position Run with `pnpm test:a11y-contract`. Focus from label activation* needs a real browser: jsdom's label activation never focuses a text input.*/@@ -37,10 +37,10 @@ test.afterAll(async () => {await storybook?.close();});-/** Opens the story and returns the Nickname label's info icon. */+/** Opens the story and returns the info button after the Nickname label. */async function openInfoIcon(page: Page): Promise<Locator> {await page.goto(`${storybook.origin}/iframe.html?id=${STORY}&viewMode=story`);- const icon = page.locator(`label[for="${FIELD_ID}"] [aria-describedby]`);+ const icon = page.locator(`label[for="${FIELD_ID}"] + button`);await icon.waitFor();return icon;}@@ -49,7 +49,7 @@ async function focusedId(page: Page): Promise<string> {return page.evaluate(() => document.activeElement?.id ?? '');}-test.describe('a touch tap on the info icon', () => {+test.describe('a touch tap on the info button', () => {test.use({hasTouch: true,isMobile: true,@@ -60,7 +60,7 @@ test.describe('a touch tap on the info icon', () => {const icon = await openInfoIcon(page);const box = await icon.boundingBox();if (box == null) {- throw new Error('the info icon has no layout box');+ throw new Error('the info button has no layout box');}await page.touchscreen.tap(box.x + box.width / 2, box.y + box.height / 2);@@ -71,15 +71,118 @@ test.describe('a touch tap on the info icon', () => {// field (which on a phone would raise the keyboard over the help).expect(await focusedId(page)).not.toBe(FIELD_ID);});++ test('a hidden label’s focused info button keeps its touch band on itself, adding no page scroll', async ({+ page,+ }) => {+ await page.goto(+ `${storybook.origin}/iframe.html?id=core-fieldlabel--hidden-label-info&viewMode=story`,+ );+ const field = page.getByRole('textbox', {name: 'Search people'});+ await field.focus();+ await page.keyboard.press('Shift+Tab');+ await expect(+ page.getByRole('button', {name: 'About Search people'}),+ ).toBeFocused();+ const overflow = await page.evaluate(() => ({+ x: document.documentElement.scrollWidth - innerWidth,+ y: document.documentElement.scrollHeight - innerHeight,+ }));+ expect(overflow.x).toBeLessThanOrEqual(0);+ expect(overflow.y).toBeLessThanOrEqual(0);+ });});-test.describe('a mouse click on the info icon', () => {- test('focuses the field, like a click anywhere else on the label', async ({+test.describe('a mouse click or a key on the info button', () => {+ test('a click shows the help and leaves the field unfocused', async ({page,}) => {const icon = await openInfoIcon(page);await icon.click();- await expect.poll(async () => focusedId(page)).toBe(FIELD_ID);+ await expect(+ page.getByRole('tooltip').filter({hasText: HELP}),+ ).toBeVisible();+ // The button sits outside the label, so the click is for its help only.+ expect(await focusedId(page)).not.toBe(FIELD_ID);+ });++ for (const [layout, name] of [+ ['a stacked Field', 'Search people'],+ ['a horizontal-labels FormLayout', 'Search teams'],+ ]) {+ test(`in ${layout}, a hidden label’s info button shows uncovered while it has keyboard focus`, async ({+ page,+ }) => {+ await page.goto(+ `${storybook.origin}/iframe.html?id=core-fieldlabel--hidden-label-info&viewMode=story`,+ );+ const field = page.getByRole('textbox', {name});+ await field.focus();+ await page.keyboard.press('Shift+Tab');+ const button = page.getByRole('button', {name: `About ${name}`});+ await expect(button).toBeFocused();+ const box = await button.boundingBox();+ if (box == null) {+ throw new Error('the focused info button has no layout box');+ }+ expect(box.width).toBeGreaterThan(8);+ const isOnTop = await page.evaluate(+ ({x, y}) => {+ const hit = document.elementFromPoint(x, y);+ return hit?.closest('button')?.getAttribute('aria-label') ?? null;+ },+ {x: box.x + box.width / 2, y: box.y + box.height / 2},+ );+ expect(isOnTop).toBe(`About ${name}`);+ });+ }++ test('on the first field of a dialog’s scrolling body, a hidden label’s focused info button stays inside the body', async ({+ page,+ }) => {+ await page.goto(+ `${storybook.origin}/iframe.html?id=core-fieldlabel--hidden-label-info-in-dialog&viewMode=story`,+ );+ const field = page.getByRole('textbox', {name: 'Search files'});+ await field.focus();+ await page.keyboard.press('Shift+Tab');+ const button = page.getByRole('button', {name: 'About Search files'});+ await expect(button).toBeFocused();+ const placement = await button.evaluate(el => {+ let scroller = el.parentElement;+ while (scroller && getComputedStyle(scroller).overflowY === 'visible') {+ scroller = scroller.parentElement;+ }+ const box = el.getBoundingClientRect();+ const view = scroller?.getBoundingClientRect();+ const hit = document.elementFromPoint(+ box.x + box.width / 2,+ box.y + box.height / 2,+ );+ return {+ isInside:+ view != null && box.top >= view.top && box.bottom <= view.bottom,+ isOnTop: hit?.closest('button') === el,+ width: box.width,+ };+ });+ expect(placement).toEqual({+ isInside: true,+ isOnTop: true,+ width: expect.any(Number),+ });+ expect(placement.width).toBeGreaterThan(8);+ });++ test('Enter shows the help and leaves the field unfocused', async ({+ page,+ }) => {+ const icon = await openInfoIcon(page);+ await icon.focus();+ await page.keyboard.press('Enter');++ await expect(icon).toHaveAttribute('aria-expanded', 'true');+ expect(await focusedId(page)).not.toBe(FIELD_ID);});});diff --git a/packages/core/src/InputGroup/InputGroup.test.tsx b/packages/core/src/InputGroup/InputGroup.test.tsxindex 6d821607a0..0e9eea69fa 100644--- a/packages/core/src/InputGroup/InputGroup.test.tsx+++ b/packages/core/src/InputGroup/InputGroup.test.tsx@@ -502,8 +502,9 @@ describe('InputGroup', () => {screen.getByRole('group').getAttribute('aria-labelledby') ?? '',);expect(label()).toHaveTextContent('Optional');- const tooltipTrigger = label()?.querySelector('.astryx-icon');- expect(tooltipTrigger).not.toBeNull();+ // The info button follows the label element, outside it.+ const tooltipTrigger = label()?.nextElementSibling;+ expect(tooltipTrigger?.tagName).toBe('BUTTON');expect(document.getElementById(tooltipTrigger?.getAttribute('aria-describedby') ?? '',