Repository navigation
fix(flyout): Close flyout when placement target unloads - #26648
Open
christo-polydorou wants to merge 1 commit into
Open
christo-polydorou wants to merge 1 commit into
christo-polydorou wants to merge 1 commit into
Conversation
Mirror WinUI's FlyoutBase::SetPlacementTarget: while open, subscribe to the placement target's Unloaded and call Hide() from it. The handler is attached next to ActualThemeChanged and detached in the same places, so the target doesn't keep the flyout alive after it closes. Removing the target during Opening cancels the open. Fixes unoplatform#26398
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub Issue: closes #26398
PR Type:
🐞 Bugfix
What changed? 🚀
If a flyout's placement target was removed from the tree while the flyout was open, the flyout just stayed open:
IsOpenstayed true, the popup was still there, andClosing/Closednever fired. On WinUI it closes.This does what WinUI does in
FlyoutBase::SetPlacementTarget: while the flyout is open, it listens to the target'sUnloadedand callsHide(). The handler is attached and detached in the same places as the existingActualThemeChangedone, so nothing is kept alive after the flyout closes.Closingcan still be cancelled, same as WinUI.This is a bit different from what I described in my comment on the issue. I dropped the
IsOpencheck in the handler. It turned out to cause a bug: if the target is removed duringOpening,IsOpenisn't set yet, so the flyout would open on a detached target. I also dropped the "detach before attach" step, sinceHide()and theTargetsetter already take care of it.Tests added to
Given_Flyout:When_Target_Removed_While_Open_ClosesWhen_Target_Removed_During_Opening_Does_Not_OpenWhen_Target_Removed_After_Closed_No_Extra_EventsWhen_Previous_Target_Removed_After_Reshown_Stays_OpenI ran
Given_Flyout,Given_MenuFlyoutandGiven_CommandBarFlyouton Skia desktop (macOS) and everything passes. The first two new tests fail without the fix. I haven't run anything on WASM or WinUI.One thing I wasn't able to check: Uno raises
Unloadedright away, so removing and re-adding the target in the same tick will close the flyout. I'm not sure whether WinUI does the same.#26399 and #26400 are related, but they need WinUI's staged flyout logic, so I'll do those in separate PRs.
PR Checklist ✅
Screenshots Compare Test Runresults.