@astryxdesign/core 0.7.2 → 0.7.3-canary.0bf23bd

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
  2. package/dist/BottomSheet/BottomSheet.js +8 -4
  3. package/dist/BottomSheet/BottomSheetSwitcher.d.ts.map +1 -1
  4. package/dist/BottomSheet/BottomSheetSwitcher.js +7 -0
  5. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  6. package/dist/CheckboxInput/CheckboxInput.js +19 -24
  7. package/dist/ClickableCard/ClickableCard.d.ts +2 -2
  8. package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
  9. package/dist/ClickableCard/ClickableCard.js +11 -9
  10. package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
  11. package/dist/CodeBlock/CodeBlock.js +11 -1
  12. package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
  13. package/dist/ComplexSelector/ComplexSelector.js +23 -5
  14. package/dist/DateInput/DateInput.d.ts +4 -4
  15. package/dist/DateInput/DateInput.d.ts.map +1 -1
  16. package/dist/DateInput/DateInput.js +27 -20
  17. package/dist/DateInput/NativeDateField.d.ts.map +1 -1
  18. package/dist/DateInput/NativeDateField.js +14 -8
  19. package/dist/DateInput/TouchDateField.d.ts.map +1 -1
  20. package/dist/DateInput/TouchDateField.js +14 -10
  21. package/dist/Dialog/Dialog.d.ts.map +1 -1
  22. package/dist/Dialog/Dialog.js +9 -4
  23. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  24. package/dist/DropdownMenu/DropdownMenu.js +52 -10
  25. package/dist/DropdownMenu/DropdownMenuContext.d.ts +34 -1
  26. package/dist/DropdownMenu/DropdownMenuContext.d.ts.map +1 -1
  27. package/dist/DropdownMenu/DropdownMenuContext.js +15 -0
  28. package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts +21 -2
  29. package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
  30. package/dist/DropdownMenu/DropdownMenuSubMenu.js +375 -42
  31. package/dist/DropdownMenu/menuRegionStops.d.ts +2 -2
  32. package/dist/DropdownMenu/menuRegionStops.js +2 -2
  33. package/dist/FileInput/FileInput.d.ts.map +1 -1
  34. package/dist/FileInput/FileInput.js +14 -12
  35. package/dist/Link/Link.d.ts +2 -3
  36. package/dist/Link/Link.d.ts.map +1 -1
  37. package/dist/Link/Link.js +11 -19
  38. package/dist/Markdown/Markdown.d.ts.map +1 -1
  39. package/dist/Markdown/Markdown.js +48 -15
  40. package/dist/MultiSelector/MultiSelector.d.ts +4 -4
  41. package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
  42. package/dist/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.d.ts +2 -0
  43. package/dist/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.d.ts.map +1 -0
  44. package/dist/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.js +48 -0
  45. package/dist/MultiSelector/MultiSelector.js +25 -18
  46. package/dist/Popover/Popover.d.ts.map +1 -1
  47. package/dist/Popover/Popover.js +8 -4
  48. package/dist/Selector/Selector.d.ts +4 -4
  49. package/dist/Selector/Selector.d.ts.map +1 -1
  50. package/dist/Selector/Selector.js +23 -14
  51. package/dist/Selector/SelectorOption.d.ts.map +1 -1
  52. package/dist/Selector/SelectorOption.js +1 -0
  53. package/dist/Slider/Slider.d.ts.map +1 -1
  54. package/dist/Slider/Slider.js +7 -14
  55. package/dist/Switch/Switch.d.ts.map +1 -1
  56. package/dist/Switch/Switch.js +25 -17
  57. package/dist/Switch/switch.markers.stylex.d.ts +2 -0
  58. package/dist/Switch/switch.markers.stylex.d.ts.map +1 -1
  59. package/dist/Switch/switch.markers.stylex.js +6 -0
  60. package/dist/TimeInput/TimeInput.d.ts +2 -1
  61. package/dist/TimeInput/TimeInput.d.ts.map +1 -1
  62. package/dist/Token/Token.d.ts.map +1 -1
  63. package/dist/Token/Token.js +8 -3
  64. package/dist/Tooltip/Tooltip.d.ts.map +1 -1
  65. package/dist/Tooltip/Tooltip.js +36 -14
  66. package/dist/Tooltip/useTooltip.d.ts.map +1 -1
  67. package/dist/Tooltip/useTooltip.js +11 -2
  68. package/dist/TopNav/TopNav.d.ts.map +1 -1
  69. package/dist/TopNav/TopNav.js +2 -2
  70. package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
  71. package/dist/TopNav/TopNavHeading.js +1 -0
  72. package/dist/Typeahead/Typeahead.d.ts.map +1 -1
  73. package/dist/Typeahead/Typeahead.js +14 -2
  74. package/dist/astryx.css +8 -2
  75. package/dist/hooks/useMenuPress.d.ts +11 -1
  76. package/dist/hooks/useMenuPress.d.ts.map +1 -1
  77. package/dist/hooks/useMenuPress.js +43 -5
  78. package/dist/utils/disabledInteraction.d.ts +21 -0
  79. package/dist/utils/disabledInteraction.d.ts.map +1 -0
  80. package/dist/utils/disabledInteraction.js +33 -0
  81. package/dist/utils/timeParser.d.ts +4 -0
  82. package/dist/utils/timeParser.d.ts.map +1 -1
  83. package/dist/utils/timeParser.js +9 -2
  84. package/package.json +4 -4
  85. package/scripts/agent-doc-state.mjs +35 -8
  86. package/src/Banner/Banner.spec.md +37 -32
  87. package/src/BottomSheet/BottomSheet.spec.md +13 -6
  88. package/src/BottomSheet/BottomSheet.test.tsx +29 -0
  89. package/src/BottomSheet/BottomSheet.tsx +8 -4
  90. package/src/BottomSheet/BottomSheetSwitcher.spec.md +121 -51
  91. package/src/BottomSheet/BottomSheetSwitcher.test.tsx +26 -0
  92. package/src/BottomSheet/BottomSheetSwitcher.tsx +6 -0
  93. package/src/CheckboxInput/CheckboxInput.test.tsx +44 -5
  94. package/src/CheckboxInput/CheckboxInput.tsx +16 -26
  95. package/src/CheckboxInput/__tests__/Checkbox.a11y.states.ts +3 -3
  96. package/src/CheckboxList/CheckboxList.test.tsx +9 -6
  97. package/src/ClickableCard/ClickableCard.doc.mjs +2 -2
  98. package/src/ClickableCard/ClickableCard.test.tsx +5 -4
  99. package/src/ClickableCard/ClickableCard.tsx +9 -9
  100. package/src/CodeBlock/CodeBlock.highlightStyles.test.tsx +87 -0
  101. package/src/CodeBlock/CodeBlock.tsx +11 -1
  102. package/src/ComplexSelector/ComplexSelector.focusableDisabled.test.tsx +76 -0
  103. package/src/ComplexSelector/ComplexSelector.tsx +21 -4
  104. package/src/ContextMenu/ContextMenu.test.tsx +41 -0
  105. package/src/DateInput/DateInput.doc.mjs +9 -8
  106. package/src/DateInput/DateInput.test.tsx +88 -13
  107. package/src/DateInput/DateInput.tsx +49 -21
  108. package/src/DateInput/DateInputTouch.test.tsx +22 -1
  109. package/src/DateInput/NativeDateField.test.tsx +29 -3
  110. package/src/DateInput/NativeDateField.tsx +20 -7
  111. package/src/DateInput/TouchDateField.tsx +24 -9
  112. package/src/DateRangeInput/DateRangeInput.spec.md +13 -13
  113. package/src/Dialog/Dialog.test.tsx +39 -0
  114. package/src/Dialog/Dialog.tsx +9 -4
  115. package/src/DropdownMenu/DropdownMenu.spec.md +33 -2
  116. package/src/DropdownMenu/DropdownMenu.tsx +79 -8
  117. package/src/DropdownMenu/DropdownMenuContext.public.test.ts +22 -0
  118. package/src/DropdownMenu/DropdownMenuContext.tsx +39 -1
  119. package/src/DropdownMenu/DropdownMenuSubMenu.doc.mjs +16 -1
  120. package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +623 -1
  121. package/src/DropdownMenu/DropdownMenuSubMenu.tsx +556 -99
  122. package/src/DropdownMenu/__tests__/SubMenuHeaderFooter.a11y.chromium.spec.ts +267 -0
  123. package/src/DropdownMenu/menuRegionStops.ts +2 -2
  124. package/src/DropdownMenu/modules/useMenuPress.spec.md +9 -0
  125. package/src/FieldStatus/FieldStatus.spec.md +3 -2
  126. package/src/FileInput/FileInput.test.tsx +30 -7
  127. package/src/FileInput/FileInput.tsx +21 -11
  128. package/src/Link/Link.test.tsx +21 -7
  129. package/src/Link/Link.tsx +16 -24
  130. package/src/Link/__tests__/Link.a11y.states.ts +1 -1
  131. package/src/Markdown/Markdown.rerender.test.tsx +143 -0
  132. package/src/Markdown/Markdown.tsx +89 -35
  133. package/src/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.ts +71 -0
  134. package/src/MultiSelector/MultiSelector.doc.mjs +5 -5
  135. package/src/MultiSelector/MultiSelector.focusableDisabled.test.tsx +121 -0
  136. package/src/MultiSelector/MultiSelector.test.tsx +49 -7
  137. package/src/MultiSelector/MultiSelector.tsx +53 -29
  138. package/src/Popover/Popover.test.tsx +15 -0
  139. package/src/Popover/Popover.tsx +19 -8
  140. package/src/PowerSearch/PowerSearchFilterEditor.test.tsx +3 -2
  141. package/src/PowerSearch/PowerSearchToken.test.tsx +7 -5
  142. package/src/Selector/Selector.doc.mjs +4 -4
  143. package/src/Selector/Selector.focusableDisabled.test.tsx +127 -0
  144. package/src/Selector/Selector.spec.md +11 -11
  145. package/src/Selector/Selector.test.tsx +64 -6
  146. package/src/Selector/Selector.tsx +51 -21
  147. package/src/Selector/SelectorOption.tsx +4 -0
  148. package/src/SideNav/SideNav.test.tsx +35 -0
  149. package/src/Slider/Slider.spec.md +11 -11
  150. package/src/Slider/Slider.test.tsx +3 -3
  151. package/src/Slider/Slider.tsx +8 -15
  152. package/src/Switch/Switch.test.tsx +85 -8
  153. package/src/Switch/Switch.tsx +26 -16
  154. package/src/Switch/__tests__/Switch.a11y.states.ts +2 -2
  155. package/src/Switch/switch.markers.stylex.ts +4 -0
  156. package/src/Table/Table.spec.md +2 -0
  157. package/src/Table/plugins/infiniteScroll/useTableInfiniteScroll.spec.md +244 -0
  158. package/src/Table/plugins/selection/useTableSelection.test.tsx +5 -3
  159. package/src/Table/plugins/virtualization/useTableVirtualization.spec.md +266 -0
  160. package/src/TimeInput/TimeInput.doc.mjs +5 -3
  161. package/src/TimeInput/TimeInput.test.tsx +20 -0
  162. package/src/TimeInput/TimeInput.tsx +2 -1
  163. package/src/Token/Token.test.tsx +26 -4
  164. package/src/Token/Token.tsx +6 -2
  165. package/src/Tokenizer/Tokenizer.spec.md +28 -28
  166. package/src/Tooltip/Tooltip.test.tsx +51 -6
  167. package/src/Tooltip/Tooltip.tsx +41 -18
  168. package/src/Tooltip/__tests__/Tooltip.a11y.chromium.spec.ts +129 -0
  169. package/src/Tooltip/__tests__/Tooltip.a11y.renders.tsx +86 -0
  170. package/src/Tooltip/__tests__/Tooltip.a11y.states.ts +132 -0
  171. package/src/Tooltip/__tests__/Tooltip.a11y.test.tsx +126 -0
  172. package/src/Tooltip/__tests__/TooltipHoverBridge.a11y.chromium.spec.ts +74 -0
  173. package/src/Tooltip/useTooltip.test.tsx +23 -0
  174. package/src/Tooltip/useTooltip.tsx +22 -9
  175. package/src/TopNav/TopNav.tsx +11 -1
  176. package/src/TopNav/TopNavHeading.tsx +1 -0
  177. package/src/TopNav/__tests__/TopNavMobileLongHeading.a11y.chromium.spec.ts +74 -0
  178. package/src/Typeahead/Typeahead.test.tsx +89 -0
  179. package/src/Typeahead/Typeahead.tsx +15 -2
  180. package/src/hooks/useMenuPress.ts +45 -7
  181. package/src/utils/disabledInteraction.ts +40 -0
  182. package/src/utils/timeParser.test.ts +11 -0
  183. package/src/utils/timeParser.ts +9 -2
@@ -271,6 +271,21 @@ const styles = stylex.create({
271
271
  '[data-astryx-press="on"]': 'scale(0.98)',
272
272
  },
273
273
  },
274
+ // A disabled input-variant trigger keeps its tab stop (`spec:AST-085` FR1),
275
+ // and the shared disabled wrapper style drops the field focus ring, so the
276
+ // trigger shows keyboard focus here instead (FR6). It keys on the trigger
277
+ // itself, a direct child, so a focused status button keeps its own outline.
278
+ triggerDisabledFocus: {
279
+ borderColor: {
280
+ default: colorVars['--color-border-emphasized'],
281
+ ':has(> [aria-disabled="true"]:focus-visible)':
282
+ colorVars['--color-accent'],
283
+ },
284
+ boxShadow: {
285
+ default: 'none',
286
+ ':has(> [aria-disabled="true"]:focus-visible)': `inset 0px 0px 0px 2px ${colorVars['--color-accent-muted']}`,
287
+ },
288
+ },
274
289
  triggerGhostDisabled: {
275
290
  backgroundImage: 'none',
276
291
  transform: {
@@ -688,8 +703,8 @@ export interface MultiSelectorProps<
688
703
  * The selected values stay visible, focusable, and included in form
689
704
  * submission, and retain their combobox identity with `aria-readonly`. The
690
705
  * selection surface and editing affordances are removed.
691
- * Unlike `isDisabled`, a read-only selector is not dimmed and stays in the
692
- * tab order. `isDisabled` takes precedence when both are set.
706
+ * Unlike `isDisabled`, a read-only selector is not dimmed and keeps its
707
+ * value in form submission. `isDisabled` takes precedence when both are set.
693
708
  * @default false
694
709
  */
695
710
  isReadOnly?: boolean;
@@ -701,8 +716,8 @@ export interface MultiSelectorProps<
701
716
  * so the reason is discoverable by keyboard and assistive technology.
702
717
  * Activation stays blocked.
703
718
  *
704
- * Use this instead of wrapping a disabled selector in `Tooltip` — disabled
705
- * controls don't emit the pointer events an external tooltip needs.
719
+ * Use this instead of wrapping a disabled selector in `Tooltip`, so the
720
+ * reason is attached to the trigger itself.
706
721
  *
707
722
  * @example
708
723
  * ```
@@ -2409,8 +2424,18 @@ export function MultiSelector<T extends MultiSelectorOptionType>({
2409
2424
  });
2410
2425
  }
2411
2426
 
2427
+ // A disabled trigger stays focusable but, like a natively disabled button,
2428
+ // runs no caller event handler other than focus and blur, and a press on it
2429
+ // reaches no handler at all (`spec:AST-085` FR2).
2430
+ const callerProps = isDisabled
2431
+ ? Object.fromEntries(
2432
+ Object.entries(rest).filter(
2433
+ ([key]) => !/^on[A-Z]/.test(key) || /^on(Focus|Blur)/.test(key),
2434
+ ),
2435
+ )
2436
+ : rest;
2412
2437
  const triggerSharedProps: React.HTMLAttributes<HTMLElement> = {
2413
- ...rest,
2438
+ ...callerProps,
2414
2439
  id: triggerId,
2415
2440
  // A caller's description is kept alongside the field's own.
2416
2441
  'aria-describedby':
@@ -2423,13 +2448,20 @@ export function MultiSelector<T extends MultiSelectorOptionType>({
2423
2448
  // Newly forwarded handlers compose component first: the built-in toggle
2424
2449
  // and keyboard model always run. `onFocus` keeps its existing caller-first
2425
2450
  // order.
2426
- onKeyDown: composeEventHandlers(onKeyDown, onKeyDownProp),
2451
+ onKeyDown: isDisabled
2452
+ ? onKeyDown
2453
+ : composeEventHandlers(onKeyDown, onKeyDownProp),
2427
2454
  onFocus: event => {
2428
2455
  onFocus?.(event);
2429
2456
  surface.onTriggerFocus(event);
2430
2457
  },
2431
- onClick: composeEventHandlers(handleTriggerButtonClick, onClick),
2432
- tabIndex: isDisabled && !showsDisabledMessage ? -1 : 0,
2458
+ onClick: isDisabled
2459
+ ? event => {
2460
+ event.preventDefault();
2461
+ event.stopPropagation();
2462
+ }
2463
+ : composeEventHandlers(handleTriggerButtonClick, onClick),
2464
+ tabIndex: 0,
2433
2465
  ...stylex.props(
2434
2466
  styles.trigger,
2435
2467
  isEffectivelyReadOnly && styles.triggerReadOnly,
@@ -2496,14 +2528,9 @@ export function MultiSelector<T extends MultiSelectorOptionType>({
2496
2528
  <>
2497
2529
  {renderTrigger(triggerProps)}
2498
2530
  {htmlName != null &&
2531
+ !isDisabled &&
2499
2532
  value.map(v => (
2500
- <input
2501
- key={v}
2502
- type="hidden"
2503
- name={htmlName}
2504
- value={v}
2505
- disabled={isDisabled}
2506
- />
2533
+ <input key={v} type="hidden" name={htmlName} value={v} />
2507
2534
  ))}
2508
2535
  {selectionSurface}
2509
2536
  </>
@@ -2541,6 +2568,10 @@ export function MultiSelector<T extends MultiSelectorOptionType>({
2541
2568
  surface.isTriggerFocusRingSuppressed &&
2542
2569
  selectorPresentationStyles.pointerRestoredFocus,
2543
2570
  isDisabled && inputWrapperStyles.disabled,
2571
+ variant === 'input' &&
2572
+ isDisabled &&
2573
+ !surface.isTriggerFocusRingSuppressed &&
2574
+ styles.triggerDisabledFocus,
2544
2575
  isEffectivelyReadOnly && styles.triggerReadOnly,
2545
2576
  variant !== 'input' && isDisabled && styles.triggerGhostDisabled,
2546
2577
  variant !== 'input' &&
@@ -2598,26 +2629,19 @@ export function MultiSelector<T extends MultiSelectorOptionType>({
2598
2629
  ? activeDescendantId
2599
2630
  : undefined
2600
2631
  }
2601
- // With a disabledMessage the trigger keeps focusability via
2602
- // aria-disabled so the reason is focus-discoverable; activation is
2603
- // still blocked by the isDisabled guards in useMultiCombobox.
2604
- disabled={isDisabled && !showsDisabledMessage}
2605
- aria-disabled={showsDisabledMessage ? 'true' : undefined}>
2632
+ // A disabled trigger keeps its tab stop and says so through
2633
+ // aria-disabled (`spec:AST-085` FR1); the isDisabled guards in
2634
+ // useMultiCombobox block every way of opening it.
2635
+ aria-disabled={isDisabled ? 'true' : undefined}>
2606
2636
  <span {...stylex.props(styles.triggerContent)}>
2607
2637
  {renderTriggerContent()}
2608
2638
  </span>
2609
2639
  </button>
2640
+ {/* A disabled selector submits no value (`spec:AST-085` FR3). */}
2610
2641
  {htmlName != null &&
2642
+ !isDisabled &&
2611
2643
  value.map(v => (
2612
- <input
2613
- key={v}
2614
- type="hidden"
2615
- name={htmlName}
2616
- value={v}
2617
- // Disabled native controls are excluded from form submission;
2618
- // mirror that for the hidden carriers.
2619
- disabled={isDisabled}
2620
- />
2644
+ <input key={v} type="hidden" name={htmlName} value={v} />
2621
2645
  ))}
2622
2646
  {isBusy && <Spinner size="sm" />}
2623
2647
  {hasClear &&
@@ -124,6 +124,21 @@ describe('Popover', () => {
124
124
  expect(screen.getByRole('button', {name: 'Open'})).toBeInTheDocument();
125
125
  });
126
126
 
127
+ it('does not open from an aria-disabled trigger', () => {
128
+ render(
129
+ <Popover content={<span>Content</span>} label="Test">
130
+ <button type="button" aria-disabled="true">
131
+ Trigger
132
+ </button>
133
+ </Popover>,
134
+ );
135
+ const trigger = screen.getByRole('button', {name: 'Trigger'});
136
+ // A click dispatched straight on the trigger, as element.click() or an
137
+ // assistive-technology activate command does (spec:AST-085 FR2).
138
+ act(() => trigger.click());
139
+ expect(trigger).toHaveAttribute('aria-expanded', 'false');
140
+ });
141
+
127
142
  it('sets aria-haspopup on trigger', () => {
128
143
  render(
129
144
  <Popover content={<span>Content</span>} label="Test">
@@ -481,12 +481,22 @@ export function Popover({
481
481
  }, [content, popover.isOpen, scheduleOverflowMeasurement]);
482
482
 
483
483
  // Shared handler for click events on the trigger button.
484
- const handleTriggerClick = useCallback(() => {
485
- if (!isEnabled) {
486
- return;
487
- }
488
- popover.toggle();
489
- }, [isEnabled, popover]);
484
+ const handleTriggerClick = useCallback(
485
+ (event?: {currentTarget: EventTarget | null}) => {
486
+ // An aria-disabled trigger stays focusable but opens nothing
487
+ // (spec:AST-085 FR2), even for a click dispatched straight on it.
488
+ const trigger = event?.currentTarget;
489
+ if (
490
+ !isEnabled ||
491
+ (trigger instanceof Element &&
492
+ trigger.getAttribute('aria-disabled') === 'true')
493
+ ) {
494
+ return;
495
+ }
496
+ popover.toggle();
497
+ },
498
+ [isEnabled, popover],
499
+ );
490
500
 
491
501
  // Shared handler for keydown events on role="button" elements.
492
502
  // Native <button> synthesizes click on Enter/Space, but role="button"
@@ -495,7 +505,7 @@ export function Popover({
495
505
  (e: KeyboardEvent) => {
496
506
  if (e.key === 'Enter' || e.key === ' ') {
497
507
  e.preventDefault();
498
- handleTriggerClick();
508
+ handleTriggerClick(e);
499
509
  }
500
510
  },
501
511
  [handleTriggerClick],
@@ -662,7 +672,8 @@ export function Popover({
662
672
  if (isRenderProp) {
663
673
  const triggerProps: PopoverTriggerRenderProps = {
664
674
  ref: popover.triggerRef,
665
- onClick: handleTriggerClick,
675
+ // The caller renders and owns this trigger element.
676
+ onClick: () => handleTriggerClick(),
666
677
  'aria-haspopup': 'dialog',
667
678
  'aria-expanded': popover.isOpen,
668
679
  'aria-controls': popover.id,
@@ -370,7 +370,8 @@ describe('PowerSearchFilterEditor', () => {
370
370
 
371
371
  expect(screen.queryByRole('button', {name: 'Delete'})).toBeNull();
372
372
  const [fieldTrigger, operatorTrigger] = selectorTriggers();
373
- expect(fieldTrigger).toBeDisabled();
374
- expect(operatorTrigger).toBeDisabled();
373
+ // Disabled triggers stay focusable (spec:AST-085 FR1).
374
+ expect(fieldTrigger).toHaveAttribute('aria-disabled', 'true');
375
+ expect(operatorTrigger).toHaveAttribute('aria-disabled', 'true');
375
376
  });
376
377
  });
@@ -218,11 +218,13 @@ describe('PowerSearchToken', () => {
218
218
  expect(onRemove).toHaveBeenCalledTimes(1);
219
219
  });
220
220
 
221
- it('disables both the activation and remove buttons when isDisabled is set', () => {
221
+ it('marks both the activation and remove buttons disabled when isDisabled is set', () => {
222
222
  renderToken({onClick: vi.fn(), onRemove: vi.fn(), isDisabled: true});
223
- expect(screen.getByRole('button', {name: 'Status: is'})).toBeDisabled();
224
- expect(
225
- screen.getByRole('button', {name: 'Remove Status: is'}),
226
- ).toBeDisabled();
223
+ // spec:AST-085 FR1: focusable, exposed through aria-disabled.
224
+ for (const name of ['Status: is', 'Remove Status: is']) {
225
+ const button = screen.getByRole('button', {name});
226
+ expect(button).not.toHaveAttribute('disabled');
227
+ expect(button).toHaveAttribute('aria-disabled', 'true');
228
+ }
227
229
  });
228
230
  });
@@ -273,7 +273,7 @@ export const docs = {
273
273
  name: 'disabledMessage',
274
274
  type: 'string',
275
275
  description:
276
- 'Explains why the selector is disabled. With isDisabled, shows a tooltip on hover/keyboard focus and keeps the trigger focusable via aria-disabled (activation stays blocked). Use this instead of wrapping a disabled Selector in Tooltip. Disabled controls swallow the hover events an external Tooltip needs.',
276
+ 'Explains why the selector is disabled. With isDisabled, shows the reason as a tooltip on hover and keyboard focus of the trigger, which stays focusable (aria-disabled) like every disabled selector; activation stays blocked. Use this instead of wrapping a disabled Selector in Tooltip.',
277
277
  },
278
278
  {
279
279
  name: 'isLabelHidden',
@@ -475,7 +475,7 @@ export const docs = {
475
475
  {
476
476
  guidance: false,
477
477
  description:
478
- 'Wrap a disabled Selector in Tooltip to explain why it is disabled; disabled triggers swallow the hover events the wrapper needs. Use the disabledMessage prop instead.',
478
+ 'Wrap a disabled Selector in Tooltip to explain why it is disabled. Use the disabledMessage prop, which attaches the reason to the trigger itself.',
479
479
  },
480
480
  ],
481
481
  anatomy,
@@ -536,7 +536,7 @@ export const docsZh = {
536
536
  {
537
537
  guidance: false,
538
538
  description:
539
- 'Wrap a disabled Selector in Tooltip to explain why it is disabled; disabled triggers swallow the hover events the wrapper needs. Use the disabledMessage prop instead.',
539
+ 'Wrap a disabled Selector in Tooltip to explain why it is disabled. Use the disabledMessage prop, which attaches the reason to the trigger itself.',
540
540
  },
541
541
  ],
542
542
  anatomy,
@@ -607,7 +607,7 @@ export const docsDense = {
607
607
  {
608
608
  guidance: false,
609
609
  description:
610
- 'Wrap a disabled Selector in Tooltip to explain why it is disabled; disabled triggers swallow the hover events the wrapper needs. Use the disabledMessage prop instead.',
610
+ 'Wrap a disabled Selector in Tooltip to explain why it is disabled. Use the disabledMessage prop, which attaches the reason to the trigger itself.',
611
611
  },
612
612
  ],
613
613
  anatomy,
@@ -0,0 +1,127 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Selector.focusableDisabled.test.tsx
5
+ * @input Uses vitest, @testing-library/react, StyleX, Selector
6
+ * @output Conformance tests for spec:AST-085 FR1–FR4 and FR6 on Selector
7
+ * @position Testing; validates the disabled trigger of Selector.tsx
8
+ */
9
+
10
+ import {describe, it, expect, vi} from 'vitest';
11
+ import {act, render, screen} from '@testing-library/react';
12
+ import userEvent from '@testing-library/user-event';
13
+ import * as stylex from '@stylexjs/stylex';
14
+ import {colorVars} from '../theme/tokens.stylex';
15
+ import {Selector} from './Selector';
16
+
17
+ type Handler = () => void;
18
+ function Harness(props: {
19
+ isDisabled: boolean;
20
+ variant?: 'input' | 'secondary' | 'ghost';
21
+ onClick?: Handler;
22
+ onKeyDown?: Handler;
23
+ onMouseDown?: Handler;
24
+ onDoubleClick?: Handler;
25
+ }) {
26
+ return (
27
+ <form aria-label="Form">
28
+ <button type="button">Before</button>
29
+ <Selector
30
+ label="Fruit"
31
+ htmlName="fruit"
32
+ options={['Apple', 'Banana']}
33
+ value="Banana"
34
+ onChange={() => {}}
35
+ {...props}
36
+ />
37
+ <button type="button">After</button>
38
+ </form>
39
+ );
40
+ }
41
+
42
+ const trigger = () => screen.getByRole('combobox', {name: 'Fruit'});
43
+
44
+ describe('Selector disabled (spec:AST-085)', () => {
45
+ it('FR1: renders no native disabled and keeps its tab stop', async () => {
46
+ const user = userEvent.setup();
47
+ const {container} = render(<Harness isDisabled />);
48
+ expect(container.querySelector('[disabled]')).toBeNull();
49
+ expect(trigger()).toHaveAttribute('aria-disabled', 'true');
50
+ await user.click(screen.getByRole('button', {name: 'Before'}));
51
+ await user.tab();
52
+ expect(trigger()).toHaveFocus();
53
+ await user.tab();
54
+ expect(screen.getByRole('button', {name: 'After'})).toHaveFocus();
55
+ });
56
+
57
+ it('FR2: no press or key opens it or reaches a caller or ancestor handler', async () => {
58
+ const user = userEvent.setup();
59
+ const handlers = {
60
+ onClick: vi.fn(),
61
+ onKeyDown: vi.fn(),
62
+ onMouseDown: vi.fn(),
63
+ onDoubleClick: vi.fn(),
64
+ };
65
+ const onAncestorClick = vi.fn();
66
+ render(
67
+ <div onClick={onAncestorClick}>
68
+ <Harness isDisabled {...handlers} />
69
+ </div>,
70
+ );
71
+ await user.dblClick(trigger());
72
+ trigger().focus();
73
+ for (const key of ['{Enter}', ' ', '{ArrowDown}', 'b']) {
74
+ await user.keyboard(key);
75
+ }
76
+ expect(trigger()).toHaveAttribute('aria-expanded', 'false');
77
+ expect(screen.queryByRole('listbox')).toBeNull();
78
+ for (const handler of [...Object.values(handlers), onAncestorClick]) {
79
+ expect(handler).not.toHaveBeenCalled();
80
+ }
81
+ });
82
+
83
+ it('FR3: submits no value while disabled', () => {
84
+ const {rerender} = render(<Harness isDisabled={false} />);
85
+ const form = () =>
86
+ screen.getByRole<HTMLFormElement>('form', {name: 'Form'});
87
+ expect(new FormData(form()).getAll('fruit')).toEqual(['Banana']);
88
+ rerender(<Harness isDisabled />);
89
+ expect(new FormData(form()).getAll('fruit')).toEqual([]);
90
+ });
91
+
92
+ it('FR4: keeps focus when it becomes disabled while focused', () => {
93
+ const {rerender} = render(<Harness isDisabled={false} />);
94
+ act(() => trigger().focus());
95
+ rerender(<Harness isDisabled />);
96
+ expect(trigger()).toHaveFocus();
97
+ });
98
+
99
+ // jsdom cannot match `:focus-visible`: compare the ring's StyleX class hash.
100
+ const RING = stylex
101
+ .props(
102
+ stylex.create({
103
+ ring: {
104
+ boxShadow: {
105
+ default: null,
106
+ ':has(> [aria-disabled="true"]:focus-visible)': `inset 0px 0px 0px 2px ${colorVars['--color-accent-muted']}`,
107
+ },
108
+ },
109
+ }).ring,
110
+ )
111
+ .className!.split(' ')
112
+ .pop()!;
113
+
114
+ it.each([
115
+ ['input', true],
116
+ ['secondary', false],
117
+ ['ghost', false],
118
+ ] as const)(
119
+ 'FR6: a disabled %s trigger carries its own ring: %s',
120
+ (variant, ring) => {
121
+ render(<Harness isDisabled variant={variant} />);
122
+ const wrapper = trigger().parentElement!;
123
+ expect(wrapper.classList.contains(RING)).toBe(ring);
124
+ expect(getComputedStyle(wrapper).cursor).toBe('default');
125
+ },
126
+ );
127
+ });
@@ -163,17 +163,17 @@ These requirements describe shipped behavior on current `main`.
163
163
 
164
164
  ### Representative states
165
165
 
166
- | State | Required invariant | Allowed variation |
167
- | ------------------------ | ----------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
168
- | closed with no value | Label and placeholder identify the field | Consumer placeholder text |
169
- | closed with a value | Selected option is represented in the trigger | Custom `renderValue` content |
170
- | pointer / popover | Anchored surface exposes the listbox without modal-dialog semantics | Default or explicit placement |
171
- | compact coarse pointer | BottomSheet exposes a modal dialog containing the listbox | Default or explicit `adaptive`, or explicit `bottom-sheet` |
172
- | searching | Visible options, keyboard navigation, and announced result count use one filter | Consumer search and empty text |
173
- | loading | Trigger is busy; empty and no-results output is suppressed | Consumer loading duration |
174
- | disabled with reason | Trigger remains focusable enough to expose the reason while activation stays blocked | Consumer reason text |
175
- | read-only | Value stays focusable and submittable; menu, clear, and disclosure affordances are absent | Value rendering, status, and busy presentation |
176
- | selected/unselected rows | Empty marks consume no width; visible marks retain space at the logical edge | State-dependent label position/width and themed indicators |
166
+ | State | Required invariant | Allowed variation |
167
+ | ------------------------ | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
168
+ | closed with no value | Label and placeholder identify the field | Consumer placeholder text |
169
+ | closed with a value | Selected option is represented in the trigger | Custom `renderValue` content |
170
+ | pointer / popover | Anchored surface exposes the listbox without modal-dialog semantics | Default or explicit placement |
171
+ | compact coarse pointer | BottomSheet exposes a modal dialog containing the listbox | Default or explicit `adaptive`, or explicit `bottom-sheet` |
172
+ | searching | Visible options, keyboard navigation, and announced result count use one filter | Consumer search and empty text |
173
+ | loading | Trigger is busy; empty and no-results output is suppressed | Consumer loading duration |
174
+ | disabled with reason | Trigger remains focusable (`spec:AST-085`) and exposes the reason; activation stays blocked | Consumer reason text |
175
+ | read-only | Value stays focusable and submittable; menu, clear, and disclosure affordances are absent | Value rendering, status, and busy presentation |
176
+ | selected/unselected rows | Empty marks consume no width; visible marks retain space at the logical edge | State-dependent label position/width and themed indicators |
177
177
 
178
178
  ### Transformation and precedence order
179
179
 
@@ -36,7 +36,7 @@ import {InternationalizationProvider} from '../i18n';
36
36
  import {defineTheme} from '../theme/defineTheme';
37
37
  import {Theme} from '../theme/Theme';
38
38
  import {generateThemeCSS} from '../theme/generateThemeRules';
39
- import {spacingVars} from '../theme/tokens.stylex';
39
+ import {colorVars, spacingVars} from '../theme/tokens.stylex';
40
40
  import {selectorPresentationStyles} from './selectorPresentation.stylex';
41
41
  import {groupStyles} from '../InputGroup/groupStyles';
42
42
 
@@ -303,6 +303,45 @@ describe('Selector', () => {
303
303
  );
304
304
  });
305
305
 
306
+ it('shows no disabled focus ring after a pointer pick (spec:AST-085 FR6)', async () => {
307
+ const field = (isDisabled: boolean) => (
308
+ <Selector
309
+ label="Fruit"
310
+ options={OPTIONS}
311
+ onChange={() => {}}
312
+ presentation="bottom-sheet"
313
+ isDisabled={isDisabled}
314
+ />
315
+ );
316
+ const {rerender} = render(field(false));
317
+ const trigger = screen.getByRole('combobox');
318
+ fireEvent.pointerDown(trigger, {pointerType: 'touch'});
319
+ fireEvent.click(trigger, {detail: 1});
320
+ const option = await screen.findByRole('option', {name: /Banana/});
321
+ fireEvent.pointerDown(option, {pointerType: 'touch'});
322
+ fireEvent.click(option, {detail: 1});
323
+ rerender(field(true));
324
+
325
+ const ring = stylex
326
+ .props(
327
+ stylex.create({
328
+ ring: {
329
+ boxShadow: {
330
+ default: null,
331
+ ':has(> [aria-disabled="true"]:focus-visible)': `inset 0px 0px 0px 2px ${colorVars['--color-accent-muted']}`,
332
+ },
333
+ },
334
+ }).ring,
335
+ )
336
+ .className!.split(' ')
337
+ .pop()!;
338
+ const wrapper = screen.getByRole('combobox').parentElement!;
339
+ expect(wrapper).toHaveClass(
340
+ stylex.props(selectorPresentationStyles.pointerRestoredFocus).className!,
341
+ );
342
+ expect(wrapper).not.toHaveClass(ring);
343
+ });
344
+
306
345
  it('uses content-hugging height without extra bottom content padding', () => {
307
346
  const source = readFileSync(
308
347
  'packages/core/src/Selector/SelectorBottomSheet.tsx',
@@ -1821,9 +1860,11 @@ describe('Selector', () => {
1821
1860
  expect(screen.getByRole('combobox')).toHaveFocus();
1822
1861
  });
1823
1862
 
1824
- it('trigger is not focusable when disabled', () => {
1863
+ it('trigger keeps its tab stop when disabled (spec:AST-085 FR1)', () => {
1825
1864
  render(<Selector label="Fruit" options={OPTIONS} isDisabled />);
1826
- expect(screen.getByRole('combobox')).toHaveAttribute('tabIndex', '-1');
1865
+ const trigger = screen.getByRole('combobox');
1866
+ expect(trigger).toHaveAttribute('tabIndex', '0');
1867
+ expect(trigger).toHaveAttribute('aria-disabled', 'true');
1827
1868
  });
1828
1869
 
1829
1870
  it('opens the listbox with ArrowDown from a focused trigger', async () => {
@@ -2715,11 +2756,12 @@ describe('Selector', () => {
2715
2756
  expect(onChange).not.toHaveBeenCalled();
2716
2757
  });
2717
2758
 
2718
- it('remains non-focusable when disabled without a reason', () => {
2759
+ it('stays focusable when disabled without a reason (spec:AST-085 FR1)', () => {
2719
2760
  render(<Selector label="Fruit" options={OPTIONS} isDisabled />);
2720
2761
  const trigger = screen.getByRole('combobox');
2721
- expect(trigger).toBeDisabled();
2722
- expect(trigger).toHaveAttribute('tabIndex', '-1');
2762
+ expect(trigger).not.toHaveAttribute('disabled');
2763
+ expect(trigger).toHaveAttribute('aria-disabled', 'true');
2764
+ expect(trigger).toHaveAttribute('tabIndex', '0');
2723
2765
  });
2724
2766
  });
2725
2767
  describe('isReadOnly', () => {
@@ -4809,6 +4851,22 @@ describe('Selector in a narrow row', () => {
4809
4851
  expect(root.getAttribute('style')).toContain('80');
4810
4852
  expect(getComputedStyle(root).minWidth).toBe('0');
4811
4853
  });
4854
+
4855
+ it('lets a narrow list shrink an option so its label can ellipsize', () => {
4856
+ render(
4857
+ <Selector
4858
+ label="Project"
4859
+ options={['An option with a deliberately long readable label']}
4860
+ value={undefined}
4861
+ onChange={() => {}}
4862
+ isDefaultOpen
4863
+ />,
4864
+ );
4865
+ const option = screen
4866
+ .getByRole('option', {hidden: true})
4867
+ .querySelector('.astryx-selector-option')!;
4868
+ expect(getComputedStyle(option).minWidth).toBe('0');
4869
+ });
4812
4870
  });
4813
4871
 
4814
4872
  describe('Selector and option actions (not adopted)', () => {