-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
Interact Outside Issue When Mounting Tooltip in Popover in separate portals #1077
Interact Outside Issue When Mounting Tooltip in Popover in separate portals #1077
Comments
This is fixed in this PR #1064 |
We need to have further discussion on this. The PR submitted reintroduces this problem: #1036 which should have never existed as it was a bug (solved by the PR that closed #1036). The issue with separate portals is that it becomes difficult to relate "stacked" portals, where they are stacked from a visual perspective and functional perspective where the following should be true given the example of a Popover open inside a Dialog:
So the question we have to consider: How do we determine if something is inside of something else that could potentially be portalled and relate those in the appropriate order to properly handle outside clicks, escape key downs, etc?
|
@huntabyte thanks for your feedback! Could you provide an example of conditional rendering that would disrupt stacks designed to track the most recent element for escape key presses and interact-outside interactions? |
Using the example from your video, if both the tooltip and popover are portalled, they will look something like this <body>
<div popover>
</div>
<div tooltip>
</div>
</body> So the content of the tooltip is no longer "inside" the popover, meaning clicks inside the tooltip would register as outside clicks. If we had the tooltip behind a conditional, it would never even exist until after the popover has already been portalled and the DOM structure has been tampered with. Meaning there is no simple way to know what popover, dialog, or whatever this tooltip once belonged to. While we could potentially use the A good way to demonstrate this is that you should be able to apply If we were using components, this may be more practical, since we can mount the component without actually rendering any content in it, similar to how radix handles the whole If you truly want to portal it to the body due to an overflow issue or otherwise, you can still do so by setting the |
@huntabyte and why would the following not work?
and another stack for escape key presses. Radix implemented the same concept |
We could do this! |
@huntabyte created a PR for what we discussed here #1080 |
Describe the bug
If you have a tooltip inside a popover and you mount the tooltip in a separate portal than the popover, if you click inside the tooltip, the popover closes while the tooltip stays open.
The reason to mount the tooltip in a separate portal is for example to prevent clipping issues if
overflow: hidden
is applied on the popover.The reason this happens is because when clicking inside the tooltip, interact outside triggers and closes the tooltip. We should not trigger interact outside when the click happens inside portals.
Screen.Recording.2024-03-08.at.6.13.40.PM.mov
And adding an
onOutsideClick
to popover withe.preventDefault()
doesn't help and introduces the following issues:Screen.Recording.2024-03-08.at.6.14.12.PM.mov
Reproduction
https://stackblitz.com/edit/github-kwo5ue?file=src%2Froutes%2F%2Bpage.svelte
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: