Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(FieldStatus): cover rounded input corners (#5769)

rubyycheunga7347036c35d
diff --git a/.changeset/attached-field-status-overlap.md b/.changeset/attached-field-status-overlap.md
new file mode 100644
index 0000000000..3e0182334b
--- /dev/null
+++ b/.changeset/attached-field-status-overlap.md
@@ -0,0 +1,9 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Extend attached field-status backgrounds behind the lower half of their
+controls so rounded and pill-shaped inputs connect without visible gaps while
+the control remains visually above and receives pointer input across the overlap.
+
+@rubyycheung
diff --git a/apps/storybook/rtl-audit/verified-not-applicable.json b/apps/storybook/rtl-audit/verified-not-applicable.json
index a2b8d50cb7..ee11dcc032 100644
--- a/apps/storybook/rtl-audit/verified-not-applicable.json
+++ b/apps/storybook/rtl-audit/verified-not-applicable.json
@@ -3,6 +3,10 @@
"component": "core/Field",
"reason": "The Core/Field stories use block-flow labels, controls, descriptions, and status text without directional icons, side-specific placement, order, scrolling, dragging, overlays, or keyboard behavior."
},
+ {
+ "component": "core/FieldStatus",
+ "reason": "FieldStatus uses block-flow message layout and logical padding and corner radii. Its status glyphs are non-directional, and it has no side-specific placement, order, scrolling, dragging, overlays, or directional keyboard behavior."
+ },
{
"component": "core/Spinner",
"reason": "No direction-sensitive visual, layout, or behavior. The ring is a concentric SVG — two <circle> elements sharing one center, sized by diameter and stroke, with no physical inset, offset, or asymmetry to mirror. Its only layout is the optional label wrapper, which is flexDirection: column + alignItems: center, so the label stacks below the ring on both axes' terms rather than beside it. The rotation keyframe (0deg to 360deg) is deliberately absolute: a loading spinner turns the same way in every locale, and mirroring it would be a bug, not RTL support."
diff --git a/apps/storybook/stories/Field.stories.tsx b/apps/storybook/stories/Field.stories.tsx
index 03839e6fe4..826487b601 100644
--- a/apps/storybook/stories/Field.stories.tsx
+++ b/apps/storybook/stories/Field.stories.tsx
@@ -247,6 +247,7 @@ export const AllVariations: Story = {
export const StatusVariants: Story = {
render: () => {
const [vals, setVals] = useState({
+ native: 'custom-value',
error: 'bad-email',
warning: 'admin',
success: 'valid-user',
@@ -261,6 +262,21 @@ export const StatusVariants: Story = {
gap: 24,
maxWidth: 400,
}}>
+ <Field
+ label="Native input"
+ inputID="native-status-input"
+ status={{
+ type: 'warning',
+ message: 'The attached status stays behind this custom control',
+ messageID: 'native-status-message',
+ }}>
+ <NativeInput
+ id="native-status-input"
+ describedBy="native-status-message"
+ value={vals.native}
+ onChange={set('native')}
+ />
+ </Field>
<TextInput
label="Email"
description="Enter your work email"
diff --git a/packages/core/src/Field/Field.doc.mjs b/packages/core/src/Field/Field.doc.mjs
index 3d6eee4444..60f1c97452 100644
--- a/packages/core/src/Field/Field.doc.mjs
+++ b/packages/core/src/Field/Field.doc.mjs
@@ -39,6 +39,7 @@ export const docs = {
],
vars: [
{name: '--_field-radius', description: 'Border radius of input fields', default: 'var(--radius-element)', private: true},
+ {name: '--_field-status-overlap', description: 'Amount an attached FieldStatus extends behind the lower half of the control. Set from the rendered control size.', default: 'calc(var(--size-element-md) / 2)', private: true},
{name: '--_input-clear-hit-inset', description: 'Outset of the clear (\u2715) button\'s invisible hit area, applied to a ::after overlay. 0 on a fine pointer; negative on a coarse one, which grows the 20px button to the 24px touch target without changing what is drawn.', default: '0px', private: true},
{name: '--_input-clear-hit-content', description: 'Whether the clear (\u2715) button\'s invisible hit overlay exists. `none` on a fine pointer, so no ::after is generated and hover still reaches the glyph; `""` on a coarse one, where the overlay provides the 24px touch target.', default: 'none', private: true},
],
diff --git a/packages/core/src/Field/Field.test.tsx b/packages/core/src/Field/Field.test.tsx
index 1c692d08ae..4b1523880c 100644
--- a/packages/core/src/Field/Field.test.tsx
+++ b/packages/core/src/Field/Field.test.tsx
@@ -27,6 +27,45 @@ afterEach(() => {
});
describe('Field', () => {
+ it.each(['sm', 'md', 'lg'] as const)(
+ 'provides a half-height overlap for an attached %s control',
+ size => {
+ render(
+ <Field
+ label="Username"
+ inputID="username"
+ status={{type: 'warning', message: 'This username may be taken'}}>
+ <div data-size={size}>Control</div>
+ </Field>,
+ );
+
+ const status = screen.getByText('This username may be taken');
+ expect(
+ getComputedStyle(status.parentElement!).getPropertyValue(
+ '--_field-status-overlap',
+ ),
+ ).toBe(`calc(var(--size-element-${size}) / 2)`);
+ },
+ );
+
+ it('layers an attached status behind a custom control', () => {
+ render(
+ <Field
+ label="Username"
+ inputID="username"
+ status={{type: 'warning', message: 'This username may be taken'}}>
+ <input id="username" />
+ </Field>,
+ );
+
+ const status = screen.getByText('This username may be taken');
+ const wrapper = status.parentElement!;
+
+ expect(getComputedStyle(wrapper).isolation).toBe('isolate');
+ expect(getComputedStyle(status).position).toBe('relative');
+ expect(getComputedStyle(status).zIndex).toBe('-1');
+ });
+
it('renders with label', () => {
render(
<Field label="Email" inputID="email-input">
diff --git a/packages/core/src/Field/Field.tsx b/packages/core/src/Field/Field.tsx
index b45af03618..c71f6383b5 100644
--- a/packages/core/src/Field/Field.tsx
+++ b/packages/core/src/Field/Field.tsx
@@ -23,7 +23,7 @@ import type {SizeValue} from '../utils/types';
import {FieldLabel} from './FieldLabel';
import {FieldStatus} from '../FieldStatus/FieldStatus';
import type {FieldStatusVariant} from '../FieldStatus/FieldStatus';
-import {spacingVars, borderVars} from '../theme/tokens.stylex';
+import {spacingVars, borderVars, sizeVars} from '../theme/tokens.stylex';
import type {IconType} from '../Icon';
import {mergeProps} from '../utils';
import {useDevWarning} from '../hooks/useDevWarning';
@@ -52,6 +52,20 @@ const styles = stylex.create({
display: 'flex',
flexDirection: 'column',
isolation: 'isolate',
+ // Extend an attached FieldStatus behind the lower half of the control.
+ // Half-height is the maximum effective corner radius CSS can render, even
+ // when a theme uses a pill value such as --radius-full (9999px).
+ '--_field-status-overlap': {
+ default: `calc(${sizeVars['--size-element-md']} / 2)`,
+ ':has(> [data-size="sm"])': `calc(${sizeVars['--size-element-sm']} / 2)`,
+ ':has(> [data-size="lg"])': `calc(${sizeVars['--size-element-lg']} / 2)`,
+ },
+ },
+ attachedStatusLayer: {
+ // Keep the overlapping background below both Astryx inputs and custom
+ // controls. The isolated wrapper contains this negative stacking layer.
+ position: 'relative',
+ zIndex: -1,
},
});
@@ -250,6 +264,9 @@ export function Field({
message={status.message}
id={resolvedMessageID}
variant={statusVariant}
+ xstyle={
+ statusVariant === 'attached' ? styles.attachedStatusLayer : undefined
+ }
/>
) : null;
diff --git a/packages/core/src/FieldStatus/FieldStatus.test.tsx b/packages/core/src/FieldStatus/FieldStatus.test.tsx
index 2d53b101f3..b7f3fcd085 100644
--- a/packages/core/src/FieldStatus/FieldStatus.test.tsx
+++ b/packages/core/src/FieldStatus/FieldStatus.test.tsx
@@ -149,6 +149,23 @@ describe('FieldStatus', () => {
expect(el).toHaveAttribute('data-variant', 'attached');
expect(el).toHaveClass('attached');
});
+
+ it('extends the attached background by the field-provided overlap', () => {
+ render(<FieldStatus type="warning" message="msg" data-testid="fs" />);
+ const styles = getComputedStyle(screen.getByTestId('fs'));
+
+ expect(styles.marginTop).toBe(
+ 'calc(-1 * var(--_field-status-overlap,var(--spacing-1-5)))',
+ );
+ });
+
+ it('does not intercept pointer input over the attached control', () => {
+ render(<FieldStatus type="warning" message="msg" data-testid="fs" />);
+
+ expect(getComputedStyle(screen.getByTestId('fs')).pointerEvents).toBe(
+ 'none',
+ );
+ });
});
describe('color styling per status type', () => {
diff --git a/packages/core/src/FieldStatus/FieldStatus.tsx b/packages/core/src/FieldStatus/FieldStatus.tsx
index 538a85569b..5160dd5c72 100644
--- a/packages/core/src/FieldStatus/FieldStatus.tsx
+++ b/packages/core/src/FieldStatus/FieldStatus.tsx
@@ -46,6 +46,8 @@ const statusIconMap: Record<InputStatusType, IconName> = {
success: 'success',
};
+const ATTACHED_OVERLAP = `var(--_field-status-overlap, ${spacingVars['--spacing-1-5']})`;
+
const styles = stylex.create({
base: {
fontFamily: typographyVars['--font-family-body'],
@@ -53,12 +55,15 @@ const styles = stylex.create({
lineHeight: typeScaleVars['--text-supporting-leading'],
},
attached: {
- marginTop: `calc(-1 * ${spacingVars['--spacing-1-5']})`,
- paddingBlockStart: `calc(${spacingVars['--spacing-1-5']} + ${spacingVars['--spacing-2']})`,
+ marginTop: `calc(-1 * ${ATTACHED_OVERLAP})`,
+ paddingBlockStart: `calc(${ATTACHED_OVERLAP} + ${spacingVars['--spacing-2']})`,
paddingBlockEnd: spacingVars['--spacing-2'],
paddingInline: spacingVars['--spacing-2'],
borderEndStartRadius: radiusVars['--radius-element'],
borderEndEndRadius: radiusVars['--radius-element'],
+ // The overlap is visual only. Let pointer input reach the control beneath
+ // it instead of allowing the later-painted status box to steal the click.
+ pointerEvents: 'none',
},
detached: {
marginTop: spacingVars['--spacing-1'],
diff --git a/packages/core/src/theme/derivedVarRegistry.test.ts b/packages/core/src/theme/derivedVarRegistry.test.ts
index d9f6feb115..42f4b5b05d 100644
--- a/packages/core/src/theme/derivedVarRegistry.test.ts
+++ b/packages/core/src/theme/derivedVarRegistry.test.ts
@@ -272,6 +272,7 @@ const VARS_WITHOUT_DERIVED_MAPPING = new Set([
'--button-focus-offset',
'--button-icon-only-aspect',
'--_avatar-group-overlap',
+ '--_field-status-overlap',
'--_codeblock-gutter-width',
'--_tab-indicator-bottom',
// Hit-area outset on a ::after overlay, and whether that overlay is