Skip to content
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

Add guard around FocusWithin responder root events #18080

Merged
merged 1 commit into from
Feb 19, 2020

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Feb 19, 2020

We've run into an interesting problem internally that is likely due to a strange set of events from the recent onBeforeBlur change, causing addRootEventTypes to try and add the same event before removing it. This change should guard the change to prevent the invariant from occuring in these cases.

I'll try and make a repro test tomorrow and see if there's an alternative way to fix this.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Feb 19, 2020
@@ -36,7 +36,7 @@ type FocusState = {
isFocused: boolean,
isFocusVisible: boolean,
pointerType: PointerType,
...
addedRootEvents?: boolean,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need to be optional?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it just boolean.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use it in the Focus responder, only the FocusWithin responder. I didn't want to add more code to the state of that responder, so I opted to keep it optional for now. Breaking all the call-sites down by alternative state would make this a far more complex PR.

@codesandbox-ci
Copy link

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.

Copy link
Collaborator

@gaearon gaearon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

@sizebot
Copy link

sizebot commented Feb 19, 2020

No significant bundle size changes to report.

Size changes (stable)

Generated by 🚫 dangerJS against c7002f7

@sizebot
Copy link

sizebot commented Feb 19, 2020

No significant bundle size changes to report.

Size changes (experimental)

Generated by 🚫 dangerJS against c7002f7

@gaearon gaearon merged commit b6c94d6 into facebook:master Feb 19, 2020
@trueadm trueadm deleted the validate-blur branch February 19, 2020 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants