Skip to content

togglePopover() algorithm does not check popover validity when force == false and when the popover visibility state is hidden #8999

Closed

Description

@nt1m

Seems like an oversight to me.

cc @josepharhar @mfreed7 @annevk

Activity

  1. added
    topic: popover
    on Mar 9, 2023
  2. nt1m commented on Mar 9, 2023

    @nt1m
    MemberAuthor

    Probably doesn't matter too much fwiw.

  3. mfreed7 commented on Mar 13, 2023

    @mfreed7
    Contributor

    Seems like an oversight to me also, but I'll let @josepharhar comment.

  4. josepharhar commented on Mar 13, 2023

    @josepharhar
    Contributor

    togglePopover just calls "hide a popover" or "show popover", and each of those algorithms check popover validity as their first step.

    Are you saying that when togglePopover decides not to do anything, we should still call check popover validity...? I don't see why we should.

  5. nt1m commented on Mar 14, 2023

    @nt1m
    MemberAuthor

    Are you saying that when togglePopover decides not to do anything, we should still call check popover validity...? I don't see why we should.

    There is this slight oddity when you call togglePopover(false) on an element with no popover attribute and it ends up doing nothing instead of throwing an exception. Seems like a bad developer experience, though not something I feel too strongly about.

  6. annevk commented on Mar 16, 2023

    @annevk
    Member

    What if we make the logic:

    1. If visibility state is showing and force is not given, or force is given and is false, then hide.
    2. Otherwise, show.
  7. nt1m commented on Jun 6, 2023

    @nt1m
    MemberAuthor

    @annevk Do you think it's still worth changing the spec given the recent changes to not throw?

    The implication of this change is that the other "check popover validity" checks (dialog, fullscreen, disconnected) would run in the cases I mentioned in the title: https://html.spec.whatwg.org/multipage/popover.html#check-popover-validity

  8. annevk commented on Jun 6, 2023

    @annevk
    Member

    We decided to not throw in certain cases. Did we decide to not throw for cases where state does not match up? It looks to me like showPopover() still throws for this condition so togglePopover() should as well.

  9. josepharhar commented on Jun 7, 2023

    @josepharhar
    Contributor

    The implication of this change is that the other "check popover validity" checks (dialog, fullscreen, disconnected) would run in the cases I mentioned in the title: https://html.spec.whatwg.org/multipage/popover.html#check-popover-validity

    So the following code would result in a call to check popover validity and possibly throw exceptions?

    const div = document.createElement('div');
    div.setAttribute('popover', 'auto');
    // don't connect to document or show
    div.togglePopover(/*force=*/false); // try to force close

    We decided to not throw in certain cases. Did we decide to not throw for cases where state does not match up? It looks to me like showPopover() still throws for this condition so togglePopover() should as well.

    So the above code I wrote should throw an exception then?

  10. nt1m commented on Jun 8, 2023

    @nt1m
    MemberAuthor

    The implication of this change is that the other "check popover validity" checks (dialog, fullscreen, disconnected) would run in the cases I mentioned in the title: https://html.spec.whatwg.org/multipage/popover.html#check-popover-validity

    So the following code would result in a call to check popover validity and possibly throw exceptions?

    const div = document.createElement('div');
    div.setAttribute('popover', 'auto');
    // don't connect to document or show
    div.togglePopover(/*force=*/false); // try to force close

    We decided to not throw in certain cases. Did we decide to not throw for cases where state does not match up? It looks to me like showPopover() still throws for this condition so togglePopover() should as well.

    So the above code I wrote should throw an exception then?

    @josepharhar Since hidePopover() wouldn't throw in this case, I would say it shouldn't (and in fact it wouldn't with the suggested change, since the check popover validity algorithm wouldn't in this case).

    But:

    const div = document.createElement('div');
    // don't set popover attribute
    // don't connect to document or show
    div.togglePopover(/*force=*/false); // try to force close

    would start throwing, unlike the current algorithm.

    Stuff in step 3. of the check popover validity would also start throwing.

  11. josepharhar commented on Jun 21, 2023

    @josepharhar
    Contributor

    Ok, I created a PR to implement this: #9451

  12. rwlbuis commented on Jun 27, 2023

    @rwlbuis

    Ok, I created a PR to implement this: #9451

    I have a similar PR for WebKit:
    WebKit/WebKit#15333

  13. added a commit that references this issue on Jun 28, 2023
    be5c890
  14. added 2 commits that reference this issue on Jul 20, 2023
    8dca00b
    d6c516a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: popover

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions