-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Portal stopPropagationEvents
is a no-op on React 17+
#6580
Comments
In real world usage, we're configuring |
Please consider undeprecating this feature, not necessarily on We're using a Some workarounds:
Suggested solution(s):
It might be nice to also have these affect the target (or have separate |
@ab-pm Great summary! I think you're right — we should consider this for the Perhaps this is implementation minutiae, but I do think this would be a new feature rather than an un-deprecation. The original feature was on I think what we need is a new feature that does support React 17+ with a different implementation or API. I like this idea:
Do you have a leaning for any of your suggested solutions? Otherwise I like that one the best. |
Yeah, it wouldn't be an un-deprecation, rather I had in mind an easy update/migration path from (deprecatd) I think the most consistent solution would be to have I think the |
Environment
@blueprintjs/[email protected]
Code Sandbox
Repository: https://github.com/gluxon/blueprint-portal-stop-propagation-test/issues
React 16 repro: https://stackblitz.com/edit/stackblitz-starters-59vq3z?file=src%2FApp.tsx
React 17 repro: https://stackblitz.com/edit/stackblitz-starters-ahwxzs?file=src%2FApp.tsx
React 18 repro: https://stackblitz.com/edit/stackblitz-starters-rj3w1c?file=src%2FApp.tsx
Steps to reproduce
Create a
<Portal>
withstopPropagationEvents={["click"]}
. The container's click handler will fire on React 17+.React 16
https://stackblitz.com/edit/stackblitz-starters-59vq3z?file=src%2FApp.tsx
react16.mov
React 17
https://stackblitz.com/edit/stackblitz-starters-ahwxzs?file=src%2FApp.tsx
react17.mov
React 18
https://stackblitz.com/edit/stackblitz-starters-rj3w1c?file=src%2FApp.tsx
react18.mov
Actual behavior
The
<Portal>
click event propagation is only stopped on React 16. It is not stopped on 17 or 18.Expected behavior
Configuring
stopPropagationEvents
stops events on React 16, 17, and 18.Possible solution
Unsure so far, but this is likely due to React 17's event handling changes.
One thing I'm noticing is that Blueprint registers the stop propagation handlers on the exact same DOM node that's eventually passed to
React.createPortal
.blueprint/packages/core/src/components/portal/portal.tsx
Line 93 in c3c1a47
I would expect this to not work. The
event.stopPropagation
probably needs to happen on a React synthetic event rather than a real DOM event for React to stop propagating its synthetic events through a portal. ThePortal
component simply renders itschildren
though, so I'm not sure if a fix is straightforward.The text was updated successfully, but these errors were encountered: