Fix SplitView stealing BackRequested when its pane is closed (#21740) - #21741
Conversation
AvaloniaUI#21740 - SplitView must not steal BackRequested when its pane is closed When the SplitView is in Overlay or CompactOverlay mode it handled the TopLevel.BackRequested event even if its pane was not open, which broke system back navigation. Now it only closes the pane and marks the event handled when the pane is actually open; otherwise the event bubbles on. Adds unit tests covering both overlay modes. @
a161068 to
d12319c
Compare
|
You can test this PR using the following package version. |
|
@alexander.marek, Please read the following Contributor License Agreement (CLA). If you agree with the CLA, please reply with the following: Contributor License AgreementContribution License AgreementThis Contribution License Agreement ( âAgreementâ ) is agreed to by the party signing below ( âYouâ ), 1. Definitions. âCodeâ means the computer software code, whether in human-readable or machine-executable form, âProjectâ means any of the projects owned or managed by AvaloniaUI OÃ and offered under a license âSubmitâ is the act of uploading, submitting, transmitting, or distributing code or other content to any âSubmissionâ means the Code and any other copyrightable material Submitted by You, including any 2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any 3. Originality of Work. You represent that each of Your Submissions is entirely Your 4. Your Employer. References to âemployerâ in this Agreement include Your employer or anyone else 5. Licenses. a. Copyright License. You grant AvaloniaUI OÃ, and those who receive the Submission directly b. Patent License. You grant AvaloniaUI OÃ, and those who receive the Submission directly or c. Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement. 6. Representations and Warranties. You represent that You are legally entitled to grant the above 7. Notice to AvaloniaUI OÃ. You agree to notify AvaloniaUI OÃ in writing of any facts or 8. Information about Submissions. You agree that contributions to Projects and information about 9. Governing Law/Jurisdiction. This Agreement is governed by the laws of the Republic of Estonia, and 10. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and AvaloniaUI OÃ dedicates this Contribution License Agreement to the public domain according to the Creative Commons CC0 1. alexander.marek doesn't seem to be a GitHub user. |
|
@cla-avalonia agree |
@gentledepp You need to change your commit settings to use an email address linked to your profile, or the CLA bot will complain each time. |
#21740 - SplitView must not steal BackRequested when its pane is closed When the SplitView is in Overlay or CompactOverlay mode it handled the TopLevel.BackRequested event even if its pane was not open, which broke system back navigation. Now it only closes the pane and marks the event handled when the pane is actually open; otherwise the event bubbles on. Adds unit tests covering both overlay modes. @ Co-authored-by: alexander.marek <alexander.marek@opti-q.com>
Fixes #21740
So while messing around with a mobile app I ran into this: on some pages the Android back button / back gesture just didâĶ nothing ðĪ
Took me a while, but the culprit turned out to be the
SplitView. When it's inOverlayorCompactOverlaymode it hooks intoTopLevel.BackRequestedso it can close its pane on back. Makes sense - except it swallowed the event (e.Handled = true) even when the pane wasn't open at all. So the back navigation never got a chance to run.The fix is tiny: if the pane is already closed, just bail out early and leave the event alone so it can bubble on to whoever actually wants to navigate back.
Behaviour now:
Handledstays false â back navigation works again ðAlso threw in a couple of unit tests (both overlay modes) so we don't accidentally start stealing the event again when the pane is closed.