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

Handle mouse events based on pointer focus for popups #10126

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sudormrfbin
Copy link
Member

This PR adds one behavioral change and one bug fix:

  • On receiving a mouse event that falls outside the popup frame, close the popup.
  • Consume all mouse events that fall inside the popup so that clicks don't "bleed" into the editor layer below.
Screencasts of old behavior (click to expand)

Click outside popup Click inside popup
popup-mouse-click-outside-bug popup-mouse-inside-bug


Commits have been arranged for ease of review as always.

Fixes issues of mouse clicks "bleeding" through into the editor when
clicked on top of popups. In previous versions, mouse events were ignored
and passed into the lower layers which resulted in editor cursor being
moved when popup areas are clicked.
@sudormrfbin sudormrfbin force-pushed the dismiss-popup-on-outside-mouse branch from acf267d to a97bf79 Compare April 3, 2024 11:04
@@ -198,20 +198,29 @@ impl<T: Component> Popup<T> {
&& y < self.area.bottom();

if !mouse_is_within_popup {
return EventResult::Ignored(None);
return EventResult::Ignored(Some(self.close_cb()));
Copy link
Member

Choose a reason for hiding this comment

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

not quite sure how I feel about closing popups without giving their contents a chance to cleanup.

I think we should emulate a c-c press here so the popup gets a chance to cleanup

Suggested change
return EventResult::Ignored(Some(self.close_cb()));
let _ = self.contents.handle_event(ctrl!(c), cx)
return EventResult::Ignored(Some(self.close_cb()));

@kirawi kirawi added A-helix-term Area: Helix term improvements S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants