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

fix: do not close popover on focusout after mousedown inside #7656

Merged
merged 1 commit into from
Aug 16, 2024

Conversation

web-padawan
Copy link
Member

@web-padawan web-padawan commented Aug 15, 2024

Description

Part of #7652

Fixes the issue that happens on click inside the popover content when focus trigger is used. In this case, focusout event occurs and the overlay unexpectedly closes despite the fact that the click was inside the overlay.

The solution is to use mousedown event listener and set a flag to ignore next focusout event, if any.
The flag is then set back to false on mouseup using a global event listener.

Can be tested with the following HTML:

<button id="button">Open</button>
<vaadin-popover for="button"></vaadin-popover>

<script type="module">
  import '@vaadin/popover';

  const popover = document.querySelector('vaadin-popover');
  popover.trigger = ['focus'];

  popover.renderer = (root) => {
    if (!root.firstChild) {
      // root.appendChild(document.createElement('input'));
      const div = document.createElement('div');
      div.textContent = 'Some text content';
      root.appendChild(div)
    }
  };
</script>

Type of change

  • Feature

Copy link

sonarcloud bot commented Aug 16, 2024

@web-padawan web-padawan merged commit c9c41af into main Aug 16, 2024
9 checks passed
@web-padawan web-padawan deleted the fix/popover-mousedown-inside branch August 16, 2024 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants