Render <MainTreeNode />
indicators in Popover.Group
only
#2634
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR improves the rendered DOM structure for
Popover
components.Some of our components auto close when you click outside of them, the
Popover
component is one of them. However, there are a few exceptions to this rule:×
to close the notification then we don't want to close the currently openPopover
.Popover.Panel
component, and the 3rd party component happens to render in its ownPortal
component and you interact with that component then we don't want it to close either.If the components are using our
Portal
component, then everything is fine, but if they are not using ours, then we have to make some assumptions. Right now, we assume that your applications is rendered in the "main" tree:All of the interactions inside the Main tree that are not happening inside the Popover are considered "outside" of the Popover. But everything happening in the other branches from the root (typically the parts we don't have control over) are considered "allowed" (this is where those notifications or 3rd party libraries are typically rendered).
Next, we require some element in the main tree so that we can run checks against this element compared to the
event.target
elements for outside click behaviour. This way we can determine where elements are and if they should trigger an outside click or not.Our
Dialog
andPopover
components render a hidden<MainTreeNode />
component for this. But everyPopover
component did this, even if you are in aPopover.Group
. This resulted in a confusisng DOM structure:If you used
ul
andli
elements, this becomes:To solve this, this PR will move the
MainTreeNode
after thePopover.Group
instead, which results in:If you used
ul
andli
elements, this becomes: