An open source design system that's fully customizable and agent ready
TypeScript
fix(lab): MobileTokenizer's closed trigger is the inline Tokenizer field's box (#8818)
Xinzi Zhou70ea85903c9c
diff --git a/packages/lab/src/MobileTokenizer/MobileTokenizer.doc.mjs b/packages/lab/src/MobileTokenizer/MobileTokenizer.doc.mjsindex a9c451b82d..eab19a5388 100644--- a/packages/lab/src/MobileTokenizer/MobileTokenizer.doc.mjs+++ b/packages/lab/src/MobileTokenizer/MobileTokenizer.doc.mjs@@ -30,7 +30,7 @@ export const docs = {{guidance: false, description: 'Do not ship stable product on this Lab API; it has no theming or spec contract yet.'},],anatomy: [- {name: 'Trigger field', required: true, description: 'Button showing tokens as a summary.'},+ {name: 'Trigger field', required: true, description: 'Button showing tokens as a summary, in the inline Tokenizer field\'s own box: same border, radius, surface, block size and token inset as the desktop field.'},{name: 'Management sheet', required: true, description: 'One searchable list with trailing checkboxes for existing items, a trailing Add action for custom text, and equal-width Clear all and Done footer actions when unfiltered. Clear all requires confirmation and stays focusable with its reason when nothing is selected; the footer is hidden while searching. Nothing of the sheet is in the page while it is closed.'},],},diff --git a/packages/lab/src/MobileTokenizer/MobileTokenizer.test.tsx b/packages/lab/src/MobileTokenizer/MobileTokenizer.test.tsxindex 1bdad40a41..029f79aec8 100644--- a/packages/lab/src/MobileTokenizer/MobileTokenizer.test.tsx+++ b/packages/lab/src/MobileTokenizer/MobileTokenizer.test.tsx@@ -17,7 +17,12 @@ import {import userEvent from '@testing-library/user-event';import {useState} from 'react';import * as stylex from '@stylexjs/stylex';-import {colorVars} from '@astryxdesign/core/theme/tokens.stylex';+import {+ colorVars,+ sizeVars,+ spacingVars,+} from '@astryxdesign/core/theme/tokens.stylex';+import {inputWrapperStyles} from '@astryxdesign/core/Field';import {MobileTokenizer, type MobileTokenizerChange} from './MobileTokenizer';import type {SearchSource, SearchableItem} from '@astryxdesign/core/Typeahead';@@ -479,7 +484,7 @@ describe('MobileTokenizer (Lab, single-sheet flow)', () => {const forced = stylex.create({trigger: {borderColor: {- default: colorVars['--color-border'],+ default: colorVars['--color-border-emphasized'],'@media (forced-colors: active)': 'GrayText',},color: {default: null, '@media (forced-colors: active)': 'GrayText'},@@ -679,6 +684,45 @@ describe('MobileTokenizer Core-sheet parity', () => {}});+ it("draws the closed trigger as the inline Tokenizer field's box: the shared input wrapper (1px emphasized border, element radius, surface), the md block size, the 3px token-row inset and gap — no 44px touch height (FR16)", () => {+ const atoms = (className: string | undefined) =>+ (className ?? '')+ .split(' ')+ .filter(name => name !== '' && !name.includes('__'));+ const inset = `calc(${spacingVars['--spacing-1']} - 1px)`;+ const own = stylex.create({+ box: {+ minHeight: sizeVars['--size-element-md'],+ paddingBlock: inset,+ paddingInline: inset,+ gap: spacingVars['--spacing-1'],+ rowGap: inset,+ flexWrap: 'wrap',+ },+ touch: {minHeight: 44},+ });+ render(+ <MobileTokenizer+ label="Tags"+ searchSource={source}+ value={[ITEMS[0], ITEMS[1]]}+ onChange={() => {}}+ />,+ );+ const trigger = screen.getByRole('button', {name: 'Tags'});+ // The very classes Core's inline field and sheet trigger compose: the+ // shared box with the field's own wrap, inset and size on top (later+ // wins per property, as in the component).+ for (const name of atoms(+ stylex.props(inputWrapperStyles.base, own.box).className,+ )) {+ expect(trigger).toHaveClass(name);+ }+ for (const name of atoms(stylex.props(own.touch).className)) {+ expect(trigger).not.toHaveClass(name);+ }+ });+it('paints the trigger on the input surface, so a status band behind it does not show through the tokens', () => {const atoms = (style: stylex.StyleXStyles) =>stylexdiff --git a/packages/lab/src/MobileTokenizer/MobileTokenizer.tsx b/packages/lab/src/MobileTokenizer/MobileTokenizer.tsxindex 00ecf86324..0eb21faab4 100644--- a/packages/lab/src/MobileTokenizer/MobileTokenizer.tsx+++ b/packages/lab/src/MobileTokenizer/MobileTokenizer.tsx@@ -51,7 +51,7 @@ import {AlertDialog} from '@astryxdesign/core/AlertDialog';import {BottomSheet} from '@astryxdesign/core/BottomSheet';import {Button} from '@astryxdesign/core/Button';import {EmptyState} from '@astryxdesign/core/EmptyState';-import {Field} from '@astryxdesign/core/Field';+import {Field, inputWrapperStyles} from '@astryxdesign/core/Field';import {useAnnounce, useMergedRefs} from '@astryxdesign/core/hooks';import {useTranslator} from '@astryxdesign/core/i18n';import {Icon} from '@astryxdesign/core/Icon';@@ -121,25 +121,37 @@ const CREATABLE_ID_PREFIX = '__xds_create__';const LIST_RENDER_BATCH_SIZE = 50;const LIST_LOAD_MORE_THRESHOLD_PX = 200;+// The inline Tokenizer's token-row inset: a token's corners (radius-1) sit+// concentric with the field's (radius-2) when inset = radius-2 − radius-1 −+// border = 3px. The same number is the row gap, so wrapped rows read evenly.+const TOKEN_ROW_INSET = `calc(${spacingVars['--spacing-1']} - 1px)`;+const styles = stylex.create({+ // The closed trigger is the inline Tokenizer field's own control box, as a+ // button — the same `inputWrapperStyles.base` box Core's sheet trigger+ // composes (`component:Tokenizer` FR16: same width, border, radius,+ // surface and `size` block size, minus only the inline input's own row),+ // so before the sheet opens the field looks the same as the desktop field.+ // The 44px thumb targets belong to the sheet's rows, not to the closed+ // field. These rules are the inline field's own on top of the shared box:+ // tokens wrap, the row inset and gap keep token and field corners+ // concentric, the block size is the `md` step, and the cursor says "press"+ // since there is no input to type into.trigger: {- display: 'flex',+ width: '100%',flexWrap: 'wrap',- alignItems: 'center',gap: spacingVars['--spacing-1'],- width: '100%',- minHeight: 44,- paddingBlock: spacingVars['--spacing-1'],- paddingInline: spacingVars['--spacing-2'],- borderWidth: 1,- borderStyle: 'solid',- borderColor: colorVars['--color-border'],- borderRadius: radiusVars['--radius-element'],- // The input surface, as Core's sheet trigger has from the shared input- // wrapper: Field's attached status band sits behind the control, and a- // transparent trigger would show it through the tokens.- backgroundColor: colorVars['--color-background-surface'],+ // Row gap matches the block inset so wrapped rows look evenly spaced.+ rowGap: TOKEN_ROW_INSET,+ minHeight: sizeVars['--size-element-md'],+ height: 'auto',+ paddingBlock: TOKEN_ROW_INSET,+ paddingInline: TOKEN_ROW_INSET,+ fontFamily: 'inherit',+ fontSize: 'inherit',+ color: 'inherit',textAlign: 'start',+ appearance: 'none',cursor: {default: 'pointer',':is(:disabled,[aria-disabled="true"])': 'default',@@ -150,7 +162,7 @@ const styles = stylex.create({// base values, since StyleX merges per property.triggerDisabled: {borderColor: {- default: colorVars['--color-border'],+ default: colorVars['--color-border-emphasized'],'@media (forced-colors: active)': 'GrayText',},color: {@@ -160,6 +172,8 @@ const styles = stylex.create({},triggerPlaceholder: {color: colorVars['--color-text-secondary'],+ // The input's text inset, so the placeholder sits where typed text would.+ paddingInline: spacingVars['--spacing-1'],},triggerPlaceholderDisabled: {color: {@@ -536,7 +550,12 @@ export function MobileTokenizer<T extends SearchableItem>({)?.(event);}}{...mergeProps(- stylex.props(styles.trigger, isDisabled && styles.triggerDisabled),+ stylex.props(+ inputWrapperStyles.base,+ styles.trigger,+ isDisabled && inputWrapperStyles.disabled,+ isDisabled && styles.triggerDisabled,+ ),className,style,)}>