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

Close Popup/Dialog by clicking any mouse button outside #1280

Merged
merged 3 commits into from
Apr 19, 2024

Conversation

MatkovIvan
Copy link
Member

@MatkovIvan MatkovIvan commented Apr 18, 2024

Proposed Changes

  • Remove condition for primary mouse button to send onClickOutside event

Testing

Test: PopupTest/DialogTest

Issues Fixed

Fixes JetBrains/compose-multiplatform#4549

@MatkovIvan MatkovIvan requested a review from m-sasha April 18, 2024 09:05
@m-sasha
Copy link
Member

m-sasha commented Apr 18, 2024

  1. I think onMouseEventOutside will get called on mouse-wheel events too. We don't want to close the layer on those.
  2. What do we want to do with mouse-wheel events here? I'm not sure...
  3. Why does onMouseEventOutside need to re-check inBounds. It would be better if DetectEventOutsideLayer checked it before calling (given the function's name).

@m-sasha
Copy link
Member

m-sasha commented Apr 18, 2024

Also, let's add unit tests for all these scenarios.

@MatkovIvan
Copy link
Member Author

  1. It's already checked (not in changed code)
  2. Left or right instead of any? 🤔 ok, probably makes sense
  3. It's called not only from there, but yes it looks like we can do that

let's add unit tests for all these scenarios.

As mentioned in the description - TBD. That's why it's in draft

@m-sasha
Copy link
Member

m-sasha commented Apr 18, 2024

  1. It's already checked (not in changed code)

Ah, right, I see it only responds to mouse pressed/released events.

Left or right instead of any? 🤔 ok, probably makes sense

Not what I meant. The layer should probably close on any button.

I'm just wondering what should be done on mouse-wheel events when they happen outside the layer bounds. Should we send them to the layers below? Do we need yet another layer flag here? Maybe something to consider & discuss later.

It's called not only from there, but yes it looks like we can do that

Either that, or rename the function.

@MatkovIvan MatkovIvan force-pushed the ivan.matkov/mouse-outside-click branch from d023b8c to a4158d7 Compare April 18, 2024 13:54
@MatkovIvan MatkovIvan marked this pull request as ready for review April 18, 2024 14:36
buttons = buttons,
button = PointerButton.Secondary
)

Copy link
Member

Choose a reason for hiding this comment

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

Should send a release here too

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it's on purpose - Popup should be closed on down event

Copy link
Member

@m-sasha m-sasha Apr 19, 2024

Choose a reason for hiding this comment

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

So dialogs close on release, but popups close on press? I see that in the code, but is there a reason for it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. TLDR - Android

@MatkovIvan MatkovIvan merged commit b6061d3 into jb-main Apr 19, 2024
6 checks passed
@MatkovIvan MatkovIvan deleted the ivan.matkov/mouse-outside-click branch April 19, 2024 12:21
MatkovIvan added a commit that referenced this pull request May 2, 2024
Fine tune #1280 change. The problem is some components like bottom sheet
or navigation drawer define custom scrim and detect click on them via
regular detection like `detectTapGestures` (that filters only primary
mouse button). So to keep things consistent, we need to revert primary
button filtering for `Dialog`, but keep it as-is for `Popup` to avoid
breaking dropdowns,

## Testing

Unit test: `DialogTest`
Try to close `Popup` and `Dialog` by outside click via mouse buttons and
touch.
This should be tested by QA

## Release Notes

### Fixes - Desktop
- _(prerelease fix)_ Fix inconsistency in closing `Dialog` by mouse
clicking on scrim that was introduced by `1.6.10-beta02`
igordmn pushed a commit that referenced this pull request May 2, 2024
Fine tune #1280 change. The problem is some components like bottom sheet
or navigation drawer define custom scrim and detect click on them via
regular detection like `detectTapGestures` (that filters only primary
mouse button). So to keep things consistent, we need to revert primary
button filtering for `Dialog`, but keep it as-is for `Popup` to avoid
breaking dropdowns,

## Testing

Unit test: `DialogTest`
Try to close `Popup` and `Dialog` by outside click via mouse buttons and
touch.
This should be tested by QA

## Release Notes

### Fixes - Desktop
- _(prerelease fix)_ Fix inconsistency in closing `Dialog` by mouse
clicking on scrim that was introduced by `1.6.10-beta02`
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.

DropdownMenu doesn't close on right-click outside
2 participants