Skip to content

chore: dedupe addEvent - #10435

Merged
yihuiliao merged 1 commit into
mainfrom
dedupe-addEvent
Aug 7, 2026
Merged

chore: dedupe addEvent#10435
yihuiliao merged 1 commit into
mainfrom
dedupe-addEvent

Conversation

@snowystinger

Copy link
Copy Markdown
Member

Closes

Pulled out of #10102 in an effort to make it smaller an easier to review

This dedupes the usage of addEvent and refactors types so they work for all call sites. It also adds unit tests for useEvent which uses addEvent.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

@rspbot

rspbot commented Aug 7, 2026

Copy link
Copy Markdown

@rspbot

rspbot commented Aug 7, 2026

Copy link
Copy Markdown
## API Changes

@react-aria/utils

/@react-aria/utils:useEvent

-useEvent <K extends keyof GlobalEventHandlersEventMap> {
+useEvent <K extends keyof EventMapType<T>, T extends EventTarget> {
-  ref: RefObject<EventTarget | null>
-  event: K | (string & {
+  ref: RefObject<T | null>
+  event: Extract<K, string> | (string & {
   
 })
-  handler?: (Document, GlobalEventHandlersEventMap[K]) => any
+  listener?: (T, EventMapType<Exclude<T, null>>[K]) => any
   options?: boolean | AddEventListenerOptions
   returnVal: undefined
 }

@rspbot

rspbot commented Aug 7, 2026

Copy link
Copy Markdown

Agent Skills Changes

Modified (2)
Install

React Spectrum S2:

npx skills add https://d1pzu54gtk2aed.cloudfront.net/pr/4ca9267a377fe5f9618990a35865debba4d20b8f/

React Aria:

npx skills add https://d5iwopk28bdhl.cloudfront.net/pr/4ca9267a377fe5f9618990a35865debba4d20b8f/

@snowystinger
snowystinger added this pull request to the merge queue Aug 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 7, 2026
@snowystinger
snowystinger added this pull request to the merge queue Aug 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 7, 2026
@yihuiliao
yihuiliao added this pull request to the merge queue Aug 7, 2026
Merged via the queue into main with commit 7638f4d Aug 7, 2026
31 checks passed
@yihuiliao
yihuiliao deleted the dedupe-addEvent branch August 7, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants