Skip to content

feat: add focus events to ColorSwatchPickerItem - #10997

Open
bellussi1 wants to merge 1 commit into
adobe:mainfrom
bellussi1:feat/color-swatch-picker-item-focus-events
Open

bellussi1 wants to merge 1 commit into
adobe:mainfrom
bellussi1:feat/color-swatch-picker-item-focus-events

Conversation

@bellussi1

Copy link
Copy Markdown
Contributor

Refs #6460

Summary

ColorSwatchPickerItem already supports HoverEvents and PressEvents, so adding FocusEvents gives keyboard and focus users parity with hover interactions and matches the collection items updated for #6460 (#10822 for GridListItem, #10857 for Table rows, and #10993 for TreeItem). This lets callers attach onFocus, onBlur, and onFocusChange directly to ColorSwatchPickerItem without tracking focus state manually via render props.

Because ColorSwatchPickerItem already forwards its props to ListBoxItem (which calls useFocus(props) and filters DOM focus handlers via filterDOMProps), the implementation only needs ColorSwatchPickerItemProps to extend FocusEvents<HTMLDivElement>. Alongside the type update in packages/react-aria-components/src/ColorSwatchPicker.tsx, I added a React Aria Components/ColorSwatchPicker Storybook file with an ItemFocusEvents story and unit tests in ColorSwatchPicker.test.js.

📝 Test Instructions

Before updating ColorSwatchPickerItemProps, adding the ItemFocusEvents story caused corepack yarn check-types to fail with TS2322: Property 'onFocus' does not exist on type 'IntrinsicAttributes & ColorSwatchPickerItemProps & RefAttributes<HTMLDivElement>'.

After updating packages/react-aria-components/src/ColorSwatchPicker.tsx:

  • corepack yarn format packages/react-aria-components/src/ColorSwatchPicker.tsx packages/react-aria-components/stories/ColorSwatchPicker.stories.tsx packages/react-aria-components/test/ColorSwatchPicker.test.js: finished on 3 files (verified LF line endings).
  • corepack yarn jest packages/react-aria-components/test/ColorSwatchPicker.test.js: 1 passed suite, 9 passed, 9 total (including keyboard transitions with Tab/ArrowRight, mouse transitions, data-focused/data-focus-visible attributes, and focused rerender stability).
  • corepack yarn jest packages/react-aria-components/test/ColorSwatchPicker.test.js packages/@adobe/react-spectrum/test/color/ColorSwatchPicker.test.js packages/react-aria-components/test/ListBox.test.js: 3 passed suites, 122 passed, 1 pre-existing skipped test, 123 total.
  • corepack yarn lint: exited 0 (yarn format:check, yarn check-types, oxlint packages with 0 warnings and 0 errors, node scripts/lint-packages.js, and yarn constraints).

Not tested locally: full monorepo yarn test, yarn test:ssr, yarn test:browser, screen reader, RTL, or interactive browser verification in Storybook (only jsdom tests and type-checking/linting were run locally).

Release impact

  • Only changes docs, tests, CI, or development tools. Nothing shipped to users changes.
  • Fixes a bug or improves existing code without changing how apps use it.
  • Adds a feature or API while keeping existing usage working.
  • May break existing usage or require changes in apps that use this code.

✅ PR Checklist

  • I followed the contributing guide.
  • I tested this change locally and included the results in Test Instructions, or explained why testing does not apply.
  • I understand and can explain every change in this PR. If I used AI assistance, I followed the AI contribution guidance. (AI assistance was used to audit remaining collection items for #6460, draft the Storybook story and Jest tests, and verify lint/type checks; all diffs and test runs were reviewed locally.)

🧢 Your Project

Personal contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants