Skip to content

Popover still opens on target click after being removed from DOM #7683

Closed

Description

@sissbruecker

Description

When a popover is removed from the DOM, clicking its target does still open it. Furthermore, the popover can then not be closed on outside click, as the respective event handler is removed in disconnectedCallback.

Expected outcome

The popover should not open anymore after being removed from the DOM, neither automatically nor programmatically. While it should remove respective listeners, we probably don't want to clear the target in case the popover is going to be attached to the DOM again.

We should also make sure that there is no reference back from the target to the popover, so that it can be GCed if there is no other reference to it.

Minimal reproducible example

<vaadin-button id="button">Discount</vaadin-button>
<vaadin-popover for="button" position="bottom-start"></vaadin-popover>
<vaadin-button id="remove-popover">Remove popover</vaadin-button>

<script type="module">
  const popover = document.querySelector('vaadin-popover');
  popover.renderer = (root) => {
    root.textContent = '20% off';
  };

  const button = document.querySelector('#remove-popover');
  button.addEventListener('click', () => {
    popover.remove();
  });
</script>

Steps to reproduce

  1. Click Remove popover
  2. Click target
  3. Notice that popover still opens
  4. Click outside the popover
  5. Nothing happens, popover doesn't close

Environment

Vaadin version(s): 24.5

Browsers

Issue is not browser related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions