Skip to content
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

Should "show popover" assert the element's popover invoker is null? #9383

Closed
mbrodesser-Igalia opened this issue Jun 5, 2023 · 13 comments · Fixed by #9397 or #9481
Closed

Should "show popover" assert the element's popover invoker is null? #9383

mbrodesser-Igalia opened this issue Jun 5, 2023 · 13 comments · Fixed by #9397 or #9481
Labels
clarification Standard could be clearer topic: popover The popover attribute and friends

Comments

@mbrodesser-Igalia
Copy link
Member

mbrodesser-Igalia commented Jun 5, 2023

At https://html.spec.whatwg.org/#show-popover before step 2. Or is it supposed to be replaceable?

@mbrodesser-Igalia mbrodesser-Igalia changed the title Repeatedly calling showPopover() updates the invoker Should "show popover" assert the element's popover invoker is null? Jun 5, 2023
@keithamus keithamus added the topic: popover The popover attribute and friends label Jun 5, 2023
@annevk annevk added the clarification Standard could be clearer label Jun 5, 2023
@annevk
Copy link
Member

annevk commented Jun 5, 2023

I'm not sure how this can be true. There's nothing preventing another invocation of showPopover().

That does seem potentially not great as you can call it from somewhere else, change popover invoker, and then get an exception.

cc @nt1m @josepharhar

@mbrodesser-Igalia
Copy link
Member Author

@annevk be aware that showPopover() (https://html.spec.whatwg.org/#dom-showpopover) invokes "show popover" with invoker = null.

@annevk
Copy link
Member

annevk commented Jun 5, 2023

Ah right, I think it can assert it then, looking at the callers.

@nt1m
Copy link
Member

nt1m commented Jun 6, 2023

Seems like a reasonable assertion to add given "hide popover" sets the invoker to null.

@nt1m
Copy link
Member

nt1m commented Jun 6, 2023

@josepharhar @mbrodesser-Igalia Would either of you be interested in making the spec PR?

@mbrodesser-Igalia
Copy link
Member Author

@josepharhar @mbrodesser-Igalia Would either of you be interested in making the spec PR?

@nt1m yes, will do it.

@josepharhar
Copy link
Contributor

I tried adding this assert in chromium, but it got hit in popover-invoker-reset.html.

In popover-invoker-reset, showPopover sets an invoker but then aborts showing the popover because the beforetoggle event handler prevents default, which then leaves us in the state where the popover has an invoker set but is closed. By calling showPopover again, the assert will be hit.

If we still want this assert then we need some way of clearing out the invoker at every exit point in showPopover or something.

@josepharhar josepharhar reopened this Jun 21, 2023
@nt1m
Copy link
Member

nt1m commented Jun 21, 2023

Should the invoker be asserted and manipulated after the "check popover validity" step?

@josepharhar
Copy link
Contributor

Should the invoker be asserted and manipulated after the "check popover validity" step?

I think that wherever we put the assert doesn't matter. As long as it's possible to have the popover's invoker set to something while the popover is closed, I believe it will be possible to hit the assert

@mbrodesser-Igalia
Copy link
Member Author

I tried adding this assert in chromium, but it got hit in popover-invoker-reset.html.

In popover-invoker-reset, showPopover sets an invoker but then aborts showing the popover because the beforetoggle event handler prevents default, which then leaves us in the state where the popover has an invoker set but is closed. By calling showPopover again, the assert will be hit.

@josepharhar: thanks for the explanation.

If we still want this assert then we need some way of clearing out the invoker at every exit point in showPopover or something.

Yes, that should work. Alternatively: postpone setting element's invoker to to invoker immediately after setting element's visibility state to showing and pass the invoker as an argument to https://html.spec.whatwg.org/#topmost-popover-ancestor and use it there.

That will be correct, because:

@mbrodesser-Igalia
Copy link
Member Author

Anyone an opinion on the two proposals (#9383 (comment) and #9383 (comment))?

CC @annevk @nt1m

@josepharhar
Copy link
Contributor

postpone setting element's invoker to to invoker immediately after setting element's visibility state to showing and pass the invoker as an argument to https://html.spec.whatwg.org/#topmost-popover-ancestor and use it there.

I prototyped this and it seems to work, so I am supportive. Lets do it!

What was the motivation for adding this assert in the first place though? Is it just that we shouldn't have an invoker set while the popover is closed because that state could be confusing?

Or is it supposed to be replaceable?

What did you mean by this?

@mbrodesser-Igalia
Copy link
Member Author

postpone setting element's invoker to to invoker immediately after setting element's visibility state to showing and pass the invoker as an argument to https://html.spec.whatwg.org/#topmost-popover-ancestor and use it there.

I prototyped this and it seems to work, so I am supportive. Lets do it!

Okay, will create a spec-patch.

What was the motivation for adding this assert in the first place though? Is it just that we shouldn't have an invoker set while the popover is closed because that state could be confusing?

Yes, exactly.

Or is it supposed to be replaceable?

What did you mean by this?

If the invoker element was supposed to stay (that is, non-null) and then be replaced by another non-null element.

mbrodesser-Igalia added a commit to mbrodesser-Igalia/html that referenced this issue Jul 3, 2023
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jul 12, 2023
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Jul 16, 2023
…r" algo. r=emilio

See
<whatwg/html#9383 (comment)>.

Differential Revision: https://phabricator.services.mozilla.com/D182709

UltraBlame original commit: 0b5333b2ef93c5e4153ac198b577c6f54c5ad538
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Jul 16, 2023
…r" algo. r=emilio

See
<whatwg/html#9383 (comment)>.

Differential Revision: https://phabricator.services.mozilla.com/D182709

UltraBlame original commit: 0b5333b2ef93c5e4153ac198b577c6f54c5ad538
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Jul 16, 2023
…r" algo. r=emilio

See
<whatwg/html#9383 (comment)>.

Differential Revision: https://phabricator.services.mozilla.com/D182709

UltraBlame original commit: 0b5333b2ef93c5e4153ac198b577c6f54c5ad538
ErichDonGubler pushed a commit to erichdongubler-mozilla/firefox that referenced this issue Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer topic: popover The popover attribute and friends
5 participants