Skip to content

Commit

Permalink
Only use the used invoker to establish popover hierarchy
Browse files Browse the repository at this point in the history
Rationale from Mason Freed as per https://chromium-review.googlesource.com/c/chromium/src/+/4429412:

Instead of using the node tree to establish the popover hierarchy, the user's behavior should matter. For example, if one popover contains a popover invoker pointing to another popover, it should matter whether that invoker is *actually used* to open the second popover.

An example:
- Component 1 is a third party widget, which uses popover
- Component 2 is another third party widget, also using popover
- A page wants to use both components separately, from separate invoking buttons.
- Component 1 also wants to be able to use Component 2, via a button within Component 1.

In this example, the page should be able to still independently use these components. So a user clicking the page's button for Component 2 is expected to close Component 1 if it's open, because that's a direct invocation of Component 2. However, if the user clicks the button within Component 1 to get Component 2, it is natural to leave Component 1 open because this is a nested call.

Important note: this often happens to be the behavior even before this change, since the user clicking on the page-level Component 2 invoking button represents a light dismiss signal for Component 1, so it closes either way. But this simplifies the logic, removing the need to track all invokers on the page, and also removing the need to continuously check whether invoker relationships have changed.

Fixes #9160, fixes #9168, and closes #9048 (as per discussion in the PR).
  • Loading branch information
josepharhar authored May 8, 2023
1 parent 3d8fca2 commit cf9625f
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -82647,16 +82647,8 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
popover</span> given <var>newPopover</var>'s parent node within the <span>flat
tree</span>.</p></li>

<li>
<p>For each <span data-x="concept-button">button</span> <var>invoker</var> that is a
<span>descendant</span> of <var>newPopover</var>'s <span>root</span>, in <span>tree
order</span>:</p>

<ol>
<li><p>If <var>invoker</var>'s <span>popover target element</span> is <var>newPopover</var>,
then run <var>checkAncestor</var> given <var>invoker</var>.</p></li>
</ol>
</li>
<li><p>Run <var>checkAncestor</var> given <var>newPopover</var>'s <span>popover
invoker</span>.</p></li>

<li><p>return <var>topmostPopoverAncestor</var>.</p></li>
</ol>
Expand Down

0 comments on commit cf9625f

Please sign in to comment.