-
Notifications
You must be signed in to change notification settings - Fork 46.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: onFocus/onBlur/onBeforeInput have a matching event type #19561
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 30c564b:
|
Details of bundled changes.Comparing: 0cd9a6d...30c564b react-dom
ReactDOM: size: 🔺+0.1%, gzip: 🔺+0.1% Size changes (experimental) |
@@ -36,7 +36,7 @@ function initializeModules(hasPointerEvents) { | |||
const forcePointerEvents = true; | |||
const table = [[forcePointerEvents], [!forcePointerEvents]]; | |||
|
|||
describe.each(table)(`useFocus`, hasPointerEvents => { | |||
describe.each(table)(`useFocus hasPointerEvents=%s`, hasPointerEvents => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was slightly confusing why we had two tests with the same name.
Details of bundled changes.Comparing: 0cd9a6d...30c564b react-dom
ReactDOM: size: 🔺+0.1%, gzip: 🔺+0.1% Size changes (stable) |
...es/react-interactions/events/src/dom/create-event-handle/__tests__/useFocus-test.internal.js
Outdated
Show resolved
Hide resolved
ff641a5
to
cc2ae0c
Compare
Hmm. I was hoping we could do this with a bit less code than creating two more functions etc. Any other ideas? |
In the end we had one component that relied on |
f98cb9b
to
30c564b
Compare
I pushed a different fix. We already have a switch so we can just reuse it to set the Added a regression suite. |
Summary
So far
event.type
always matched the listener name in React even though the underlying native event might be a different type (e.g.onMouseEnter
). The recent changes to focus events madeonFocus
andonBlur
the only two events whoseevent.type
did not match (onFocus
->focusin
,onBlur
->focusout
).This PR restores the previous event types.
Closes #19560
Test Plan
It might make sense to write a regression test suite (similar to #19483) for all event types since it seems that
event.type
isn't tested. I could split this work up into two PRs (one for the test, one for the fix) in case you need to revert the fix.