-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Update popups and flyouts to properly support OverlayDismissEventPassThrough #15517
Update popups and flyouts to properly support OverlayDismissEventPassThrough #15517
Conversation
…o possibly closing the popup when a pointer is pressed. Added the PopupFlyoutBase.OverlayDismissEventPassThrough property and updated logic in Button.
…l. This was problematic when the popup was open with OverlayDismissEventPassThrough and clicking onto another control. Focus would not move to the clicked control.
|
@cla-avalonia agree |
@billhenn thanks! Would it be possible to add some tests for Flyout control at least? https://github.com/AvaloniaUI/Avalonia/blob/master/tests/Avalonia.Controls.UnitTests/FlyoutTests.cs Also, Clicking_On_Control_PseudoClass test is failing now with this PR, for some reason pseudoclasses are not applied. |
…nize pseudo-class behavior change.
You can test this PR using the following package version. |
You can test this PR using the following package version. |
…Through (#15517) * Updated Popup to raise the pass-through overlay dismiss event prior to possibly closing the popup when a pointer is pressed. Added the PopupFlyoutBase.OverlayDismissEventPassThrough property and updated logic in Button. * Updated SplitButton logic to handle OverlayDismissEventPassThrough scenarios. * Updated CalendarDatePicker logic to handle OverlayDismissEventPassThrough scenarios. * Updated ComboBox logic to handle OverlayDismissEventPassThrough scenarios. * Removed unncessary ComboBox.PopupClosed logic that focused the control. This was problematic when the popup was open with OverlayDismissEventPassThrough and clicking onto another control. Focus would not move to the clicked control. * Fixed the Clicking_On_Control_PseudoClass unit test to properly recognize pseudo-class behavior change. * Added a couple unit tests to FlyoutTests.
…Through (#15517) * Updated Popup to raise the pass-through overlay dismiss event prior to possibly closing the popup when a pointer is pressed. Added the PopupFlyoutBase.OverlayDismissEventPassThrough property and updated logic in Button. * Updated SplitButton logic to handle OverlayDismissEventPassThrough scenarios. * Updated CalendarDatePicker logic to handle OverlayDismissEventPassThrough scenarios. * Updated ComboBox logic to handle OverlayDismissEventPassThrough scenarios. * Removed unncessary ComboBox.PopupClosed logic that focused the control. This was problematic when the popup was open with OverlayDismissEventPassThrough and clicking onto another control. Focus would not move to the clicked control. * Fixed the Clicking_On_Control_PseudoClass unit test to properly recognize pseudo-class behavior change. * Added a couple unit tests to FlyoutTests.
We have found that clicking outside of popups/flyouts takes an extra click, since the first click dismisses the popup, and a second click is required to focus/activate whatever target control was clicked. This is a productivity annoyance to desktop users who are used to single clicking on a control outside of a popup to focus/activate it.
There is a
Popup.OverlayDismissEventPassThrough
property that can be set totrue
, which is meant to help with this. However, flyouts don't support it at all, and the pass-through event should be raised prior to the dismiss overlay closing the popup. This is in case the pass-through event closed the popup already, which should occur inButton
,ComboBox
, and several other native controls.Related Issues/PRs
A related issue was opened recently by another user, requesting that
OverlayDismissEventPassThrough
be added toPopupFlyoutBase
.Another past PR worked to prevent
Button
with a flyout open from closing and instantly reopening the flyout when it was clicked. It accomplished this by forcing the flyout popup'sOverlayDismissEventPassThrough
property tofalse
. While it achieved that goal, it prevented flyouts from ever supporting event pass-through, which is not ideal.Goals
The intended goal of the code changes in this new PR are:
OverlayDismissEventPassThrough
is supported on bothPopup
andPopupFlyoutBase
.OverlayDismissEventPassThrough
istrue
, any clicks to another control outside of the popup will work as expected, thereby preventing a second click from being necessary to dismiss the popup.OverlayDismissEventPassThrough
istrue
.OverlayDismissEventPassThrough
isfalse
, the same run-time behavior should be achieved as before this PR.OverlayDismissEventPassThrough
scenario, so they can close their own popup.Implementation Details
Popup
PointerPressedDismissOverlay
logic so the pass-through event fires first, then the popup is closed if the pass-through event didn't already close it.PopupFlyoutBase
OverlayDismissEventPassThrough
property and assign it to thePopup
used by the flyout.CreatePopup
method to remove thePopup.OverlayDismissEventPassThrough
from always beingfalse
.Button
OnPointerPressed
to watch forOverlayDismissEventPassThrough
scenarios when a flyout is open and close the flyout without marking the button as pressed.SplitButton
PreviewPointerPressed
handler to watch forOverlayDismissEventPassThrough
scenarios when a flyout is open and close the flyout.CalendarDatePicker
DropDownButton_PointerPressed
to watch forOverlayDismissEventPassThrough
scenarios when a flyout is open and close the flyout.ComboBox
OnPointerPressed
to watch forOverlayDismissEventPassThrough
scenarios when a drop-down is open and close the drop-down. If no popup is open, theComboBox
is flagged as pressed.OnPointerReleased
to only open the drop-down if theComboBox
is flagged as pressed.PopupClosed
logic to remove code that blindly focuses itself when the drop-down closes. This was bad because whenOverlayDismissEventPassThrough
wastrue
on theComboBox
's popup, clicking on an external control while the drop-down was open would not let the other control get focus. With the focus code removed, theComboBox
is still properly focused when the popup is closed by clicking on theComboBox
, pressingEsc
, etc. Therefore, the focus code was removed since it was unnecessary and caused problems.Contact me if you have any questions on the code changes.