An open source design system that's fully customizable and agent ready
TypeScript
fix(DateInput): the sheet-backed field is the same height as every other input on touch (#5534)
Xinzi Zhou70988c2edc45
diff --git a/.changeset/dateinput-touch-field-height.md b/.changeset/dateinput-touch-field-height.mdnew file mode 100644index 0000000000..eb79a10191--- /dev/null+++ b/.changeset/dateinput-touch-field-height.md@@ -0,0 +1,17 @@+---+'@astryxdesign/core': patch+---++[fix] DateInput's sheet-backed field is the same height as every other input on touch++`TouchDateField`'s closed field carried a 44px `minBlockSize` floor on a coarse+pointer, so on a phone it rendered 12px taller than the TextInput beside it —+and taller than the same component's own native surface, which is what+`DateInput` renders by default on touch. Two `DateInput`s in one form could+therefore differ in height purely by `nativePicker`.++The floor is gone from the closed field; every target inside the open sheet+keeps its 44px. The field's own floor is core's, 24x24 under WCAG 2.5.8 AA,+which a 32x180 field clears several times over.++@imdreamrunnerdiff --git a/packages/core/src/DateInput/DateInputTouch.test.tsx b/packages/core/src/DateInput/DateInputTouch.test.tsxindex 09626d3cd3..7147849c49 100644--- a/packages/core/src/DateInput/DateInputTouch.test.tsx+++ b/packages/core/src/DateInput/DateInputTouch.test.tsx@@ -335,7 +335,12 @@ describe('DateInput — surface selection', () => {setViewport('desktop');const onChange = vi.fn();render(- <DateInput nativePicker="never" label="Event date" onChange={onChange} min={undefined} />,+ <DateInput+ nativePicker="never"+ label="Event date"+ onChange={onChange}+ min={undefined}+ />,);fireEvent.change(field(), {target: {value: '2026-03-25'}});expect(onChange).toHaveBeenCalledWith('2026-03-25');@@ -380,7 +385,12 @@ describe('DateInput — field parity', () => {expect(field()).toHaveValue('');expect(field()).toHaveAttribute('placeholder', 'Select a date');rerender(- <DateInput nativePicker="never" label="Ship date" value="2026-03-21" onChange={() => {}} />,+ <DateInput+ nativePicker="never"+ label="Ship date"+ value="2026-03-21"+ onChange={() => {}}+ />,);expect(field()).toHaveValue('March 21, 2026');});@@ -477,7 +487,13 @@ describe('DateInput — field parity', () => {it('does not open the picker until the field is tapped', () => {withLayout(() => {- render(<DateInput nativePicker="never" label="Ship date" onChange={() => {}} />);+ render(+ <DateInput+ nativePicker="never"+ label="Ship date"+ onChange={() => {}}+ />,+ );expect(field()).toHaveAttribute('aria-expanded', 'false');expect(screen.queryByRole('grid')).not.toBeInTheDocument();fireEvent.click(field());@@ -495,7 +511,14 @@ describe('DateInput — field parity', () => {});it('is not openable while disabled', () => {- render(<DateInput nativePicker="never" label="Ship date" isDisabled onChange={() => {}} />);+ render(+ <DateInput+ nativePicker="never"+ label="Ship date"+ isDisabled+ onChange={() => {}}+ />,+ );expect(field()).toBeDisabled();fireEvent.click(field());expect(screen.queryByRole('grid')).not.toBeInTheDocument();@@ -538,12 +561,21 @@ describe('DateInput — field parity', () => {});it('marks required for assistive technology', () => {- render(<DateInput nativePicker="never" label="Ship date" isRequired onChange={() => {}} />);+ render(+ <DateInput+ nativePicker="never"+ label="Ship date"+ isRequired+ onChange={() => {}}+ />,+ );expect(field()).toHaveAttribute('aria-required', 'true');});it('associates the label natively, so the field is named without ARIA', () => {- render(<DateInput nativePicker="never" label="Ship date" onChange={() => {}} />);+ render(+ <DateInput nativePicker="never" label="Ship date" onChange={() => {}} />,+ );expect(screen.getByLabelText('Ship date')).toBe(field());});@@ -666,7 +698,13 @@ describe('DateInput — calendar surface', () => {it('Save closes even with no date chosen, committing nothing', () => {const onChange = vi.fn();withLayout(() => {- render(<DateInput nativePicker="never" label="Ship date" onChange={onChange} />);+ render(+ <DateInput+ nativePicker="never"+ label="Ship date"+ onChange={onChange}+ />,+ );fireEvent.click(field());fireEvent.click(screen.getByRole('button', {name: 'Save'}));});@@ -2423,18 +2461,27 @@ describe('DateInput — scroll CSS (definition-level)', () => {expect(footer).not.toContain('paddingInline');});- it('floors the touch target without discarding the size prop', () => {- const source = read('TouchDateField.tsx');- // Each size keeps its own height AND cannot render below a thumb's reach.- const sizeMap = source.slice(- source.indexOf('const sizeStyles = stylex.create('),- source.indexOf('const styles = stylex.create('),+ it('sizes the closed field the same on both surfaces', () => {+ // `DateInput` picks a surface from the pointer and `nativePicker`, so a+ // field that sizes itself differently on one of them changes height for+ // a reason the call site never asked about.+ //+ // Compared with formatting normalized away: the two files write the same+ // declarations differently, one entry per line against one per size.+ const sizeMap = (file: string) => {+ const source = read(file);+ const start = source.indexOf('const sizeStyles = stylex.create(');+ expect(start).toBeGreaterThan(-1);+ return source+ .slice(start, source.indexOf('});', start))+ .replace(/\/\/.*$/gm, '')+ .replace(/\/\*[\s\S]*?\*\//g, '')+ .replace(/\s+/g, '')+ .replace(/,(?=[}\]])/g, '');+ };+ expect(sizeMap('TouchDateField.tsx')).toEqual(+ sizeMap('NativeDateField.tsx'),);- expect(- sizeMap.match(- /minBlockSize: \{default: null, '@media \(pointer: coarse\)': TOUCH_TARGET\}/g,- ),- ).toHaveLength(3);});it('floors the month arrows too — Button tops out at 36px', () => {diff --git a/packages/core/src/DateInput/TouchDateField.tsx b/packages/core/src/DateInput/TouchDateField.tsxindex 212ba03804..c3ef021048 100644--- a/packages/core/src/DateInput/TouchDateField.tsx+++ b/packages/core/src/DateInput/TouchDateField.tsx@@ -122,9 +122,8 @@ import {import {dateInputTouchSizes, dateInputTouchGeometry} from './tokens.stylex';/**- * The comfortable minimum tap target on both iOS and Android. Applied as a- * FLOOR under the size prop rather than replacing it: `size` still means what- * it means, it just cannot produce a control a thumb misses.+ * The comfortable minimum tap target on both iOS and Android, honoured by+ * every target inside the sheet.*/const TOUCH_TARGET = dateInputTouchSizes.daySize;@@ -151,17 +150,14 @@ const sizeStyles = stylex.create({sm: {height: sizeVars['--size-element-sm'],minWidth: 180,- minBlockSize: {default: null, '@media (pointer: coarse)': TOUCH_TARGET},},md: {height: sizeVars['--size-element-md'],minWidth: 180,- minBlockSize: {default: null, '@media (pointer: coarse)': TOUCH_TARGET},},lg: {height: sizeVars['--size-element-lg'],minWidth: 180,- minBlockSize: {default: null, '@media (pointer: coarse)': TOUCH_TARGET},},});@@ -286,7 +282,7 @@ const styles = stylex.create({/*** `Button`'s own sizes top out at 36px, which is fine for a mouse and short* of the 44px every other target in this sheet honours. Floor it on a- * coarse pointer, the same way the field and the day cells do.+ * coarse pointer, the same way the day cells do.*/monthArrow: {minBlockSize: {default: null, '@media (pointer: coarse)': TOUCH_TARGET},