-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
removed e.stopPropagation() from onKeyDown #2354
Conversation
Hey, @dannify I've simply deleted the stopPropagation function which in turn solves the issue for us! Let me know if I have to make any more changes. |
Hey @dannify please let me know if this is okay |
@Anuragtech02 looks like one of the tests is failing (useMenuTrigger test). Mind mocking the isPropagationStopped call in that test to fix it?
|
Sure, I'll give it a try! |
Hey @LFDanLu, seems like some tests are still failing! I'm not able to understand what are they. Please let me know I'll fix those. |
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.
LGTM. @Anuragtech02 the tests are passing on the commit, what test failures are you running into?
Surprisingly the tests passed! I don't know why but I did have one test which failed but now all are passing. Anyways, let me know if I have to make any more changes. |
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.
So I was just testing this out with yarn start:docs
, I'm still seeing the warning. It seems to be because we spread the synthetic event into a new object https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria/interactions/src/createEventHandler.ts#L27
this results in all getters on the event object being invoked, of which isPropagationStopped is one and it gets frozen as functionThatReturnsFalse
I think we just need one adjustment though.
Add this to the event in the createEventHandler
isPropagationStopped(): boolean {
return e.isPropagationStopped();
}
UPDATE: Talked with Daniel some more, we've come to the conclusion that even with the change I requested here, it'll still have the same problem, due to the fact that we call stopPropagation AFTER the handler, meaning useMenuTrigger won't be able to check if propagation has been stopped yet. All that to say, let's just delete the two stopPropagation lines. Sorry for the confusion.
@snowystinger I'm sorry but I didn't quite get it. Am I supposed to remove the e.stopPropagation() line completely and not even check if propagation is stopped? |
Correct. We're going to remove it. Reasoning being that you very likely need to usePress since we're passing press events around, and there are a few other things that just make it easier if you use it with react aria, so in all likelihood, we've already stopped propagation at this point. No need to check. |
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.
LGTM, tested locally and confirmed that the warning no long appears. Apologies for the back and forth regarding the fix, and thanks for working on this!
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.
lgtm, and as @LFDanLu said, thanks for the patience!
Closes #2263
✅ Pull Request Checklist:
📝 Test Instructions:
In order to test the PR, you can go the this link and try accessing the select box with arrow keys on the keyboard. Keep the terminal open along with this to check if it logs any errors.
This PR fixes the error mentioned in the issue.