-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Introducing ReactDOM unstable_createSandboxedPortal #11930
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Before merging this we need to decide in the issue what this is trying to solve. Are we saying that this is the best permanent and consistent way to design apps (I find the arguments unconvincing so far since it doesn't address a consistent component design pattern that works for both inline layouts and floating modals)? Or is this an upgrade path mitigate for prevalent existing patterns, while not great, are hard to upgrade from (a more convincing argument)? |
@sebmarkbage what is the argument for events bubbling up through Portals, despite the fact that they are rendered outside the parent's tree? |
personally I almost always want the new behavior. Take dropdown lists, generally they are structured like: <div>
<input />
<ul>...</ul>
</div> However the dropdown menu (ul) often must actually be appended to Overall the general "point" of the portal bubbling behavior is that, things are really mostly rendered into portals in order to handle needing to appease the underlying rendering target DOM, In an ideal world positioning an overlay to a button wouldn't actually require appending it else where in the DOM, and then pretending like it's a child of a element by positioning it next to it. |
I spend a lot of time on focus management and I don't find that case convincing -- while the popup is open, it is essentially modal, and so focus will never be outside of it. Once it closes, focus can return to the dropdown. Why do you need focus bubbling here? I think all you need is to pass an onClosed callback into the popup component. In any case, I think this is still the smaller use case. I don't think it justifies all portals working this way for all events. By contrast, In the case of e.g. a popup dialog, the bubbling behavior makes basically zero sense. I think the fact that we feel so differently about it only suggests that this needs to be a configurable behavior. It sounds like both scenarios will be useful and important. If we want to get real crazy, Portals could accept a whitelist of events to bubble. I think it will be more common that there is a small set of events you want to be able to bubble through a portal -- e.g. the focus events in your example. |
I'm also very familiar with focus management in these situations :) being the author of a suite of react inputs like dropdowns and I can attest to:
not being a common situation in this use-case, unless one expects not to be able to type into a combobox while it's open. I'm not trying to devalue you usecases btw, merely state my own as also valid |
@jquense great points! I apologize if my comment sounded condescending or anything like that. I think I'm still in the same place: I think we need both behaviors. Not sure what the right API is, but I don't think it can only be one or the other. |
@jquense coming back to this -- do you think the bubbling up case is common enough that this should be the default API? It seems like it would be more Reacty and (dare I say) more sensible to just pass the necessary callbacks as props from the combobox component to the popup component -- e.g. |
Hey! I'm sorry we never got back to you about this but it seems this is now really outdated. If this is something that still makes sense to the latest master version of React, please send a new PR with this change :) |
This pull request is related to #11387 issue.
My questions:
ReactTreeTraversal
getParent
with additional condition?TypeOfWork
to introducecreateSandboxedPortal
feature or can I useHostPortal
with additional property as I made now?