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: close popover with hover trigger on target mousedown #8216

Closed
wants to merge 1 commit into from

Conversation

web-padawan
Copy link
Member

Description

Fixes #8197

Added logic to close the popover on mousedown to align with the tooltip behavior.

Note: when using hover and click triggers this isn't used since in this case the click event would immediately reopen the popover previously closed on mousedown. However, I think this combination shouldn't be widely used.

Type of change

  • Bugfix

@@ -550,6 +551,7 @@ class Popover extends PopoverPositionMixin(
target.addEventListener('click', this.__onTargetClick);
target.addEventListener('mouseenter', this.__onTargetMouseEnter);
target.addEventListener('mouseleave', this.__onTargetMouseLeave);
target.addEventListener('mousedown', this.__onTargetMouseDown);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't solve the issue if the dialog is opened with keyboard.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I didn't consider this case. Maybe we should close it on click from keyboard even if the popover doesn't have click trigger.

Copy link
Member Author

@web-padawan web-padawan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's one problem when setting popover.trigger = ['hover', 'focus'];:

popover-wtf.mp4

This makes sense since mousedown is not prevented and triggers focusin event and the popover re-opens on focus. Note: in vaadin-tooltip we don't have this problem since unlike the popover, tooltip only opens on keyboard focus.

Maybe there should be some way to notify previous overlays in the stack when a new one is opened so they could decide whether they should close or not (e.g. in case of vaadin-popover it might make sense to close it when it was opened on hover and the new overlay is not a "nested" one).

I'll close the PR for now and will continue investigating.

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

Successfully merging this pull request may close these issues.

[popover] Popover opened on hover stays open if target click opens the dialog
2 participants