Repository navigation
Open Flyout IsOpen through ShowAt so Button targets don't throw - #1420
Alexandre Zollinger Chohfi (azchohfi) merged 5 commits into
Conversation
FlyoutElement.IsOpen opened via FlyoutBase.ShowAttachedFlyout(target), but
SetFlyoutOnControl installs the flyout in a Button/SplitButton target's own
Flyout property, so WinUI threw ArgumentException ("ShowAttached was called
on an element without an attached FlyoutBase") on mount with IsOpen = true and
on every false -> true edge, replacing the tree with the render-error screen.
Open through the installed flyout's ShowAt (deferred to Loaded at mount), the
path CommandBarFlyout already uses, with a FlyoutElement-specific guard.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 13197b60-3286-41ea-a8d9-66f0f7c161dc
There was a problem hiding this comment.
🟢 Approval recommended
The narrow lifecycle fix preserves existing trigger semantics and includes targeted regression coverage, with no unresolved blocking findings.
No open issues 🎉
What changed in this PR
Fixes state-driven FlyoutElement.IsOpen opening on Button/SplitButton targets by using the installed flyout’s ShowAt method rather than attached-flyout lookup. The separate SettingsExpander issue remains outside this PR.
Changes:
- Reuses the deferred-opening helper with an element-specific guard against stale open requests.
- Adds live regression fixtures and unit tests for the deferred-open guard.
- Documents the existing one-shot
IsOpensemantics and records the fix in the changelog.
| File | Description |
|---|---|
| tests/Reactor.Tests/FlyoutAttachmentTests.cs | Tests accepted and rejected deferred-open guard inputs. |
| tests/Reactor.AppTests.Host/SelfTest/SelfTestFixtureRegistry.cs | Registers the three new regression fixtures. |
| tests/Reactor.AppTests.Host/SelfTest/Fixtures/FlyoutIsOpenStateFixtures.cs | Covers state-driven opening, reopening, mount-time opening, and attached-slot targets. |
| src/Reactor/Core/V1Protocol/OverlayLifecycle.cs | Opens installed flyouts through the shared, guarded ShowAt helper. |
| src/Reactor/Core/Element.cs | Documents the existing FlyoutElement.IsOpen trigger semantics. |
| CHANGELOG.md | Records the opening fix for issue #1419. |
Review effort: Balanced
📦 Build metricsArtifact sizes for Packages (compressed .nupkg)
Assemblies in Microsoft.UI.Reactor
Assemblies in Microsoft.UI.Reactor.Advanced
Assemblies in Microsoft.UI.Reactor.Devtools
No size change beyond the noise floor. ✅ ✅ smaller / |
🧪 Merged coverageCoverage for
No coverage change beyond the noise floor. ✅ ✅ higher / |
…hosted-item-updates # Conflicts: # CHANGELOG.md
Use a null-guarded identity helper for the target-survives check instead of a bare ReferenceEquals (github-code-quality), so two missing controls can't pass it. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 13197b60-3286-41ea-a8d9-66f0f7c161dc
…hosted-item-updates # Conflicts: # CHANGELOG.md
…hosted-item-updates # Conflicts: # CHANGELOG.md
377ca2b
into
main
Summary
Flyout(Button(...), ...) with { IsOpen = open }replaced the whole window with the render-error screen onsetOpen(true)(and on mount withIsOpen = true).OverlayLifecycleopened the flyout withFlyoutBase.ShowAttachedFlyout(target), butSetFlyoutOnControlputs a Button/SplitButton target's flyout in the control's ownFlyoutproperty, so WinUI threwArgumentException("ShowAttached was called on an element without an attached FlyoutBase").The fix opens through the installed flyout's
ShowAt, using theShowFlyoutWhenReadyhelperCommandBarFlyoutalready relies on (deferred to the target'sLoadedat mount). The helper now takes the element-typed guard (IsFlyoutStillRequestingOpenforFlyoutElement), so a deferred open is dropped if the element was re-rendered closed, replaced, or recycled. Both the button slot and the attached slot open.FlyoutElement.IsOpengets a doc comment matchingCommandBarFlyoutElement.IsOpen: it is a one-shot open trigger (shown on mount and on the false → true edge), and setting it back tofalsedoes not close the flyout. That is unchanged behaviour.MenuFlyouthas noIsOpen, andCommandBarFlyoutalready usedShowAt.The second bug in #1419 (a wrapped
SettingsExpander's items never update) has the same root cause as #1362 and is fixed by the open PR #1363, so it is deliberately left out of this PR.Linked issue / spec
Fixes #1419 (the Flyout half; the SettingsExpander half is #1362 / #1363).
Test plan
tests/Reactor.AppTests.Host/SelfTest/Fixtures/FlyoutIsOpenStateFixtures.cs, all of which assert that no render error occurred and that the flyout opened:FlyoutIsOpen_ButtonTargetFromState: the reported repro. Opens from state, dismisses,OnClosedresets the state, and a second rising edge re-opens it.FlyoutIsOpen_ButtonTargetOnMount:IsOpen = trueat mount.FlyoutIsOpen_NonButtonTargetFromState: attached-slot positive control.OverlayLifecyclechange reverted, the two Button-target fixtures fail 8 checks (FlyState_NoRenderError[Reconcile:ArgumentException…],FlyMount_NoRenderError[…], and the open/survive checks). With the fix, all pass.tests/Reactor.Tests/FlyoutAttachmentTests.cs(FlyoutDeferredOpen_*).dotnet run --project tests/Reactor.AppTests.Host --no-build -c Debug -p:Platform=x64 -- --self-test --filter <prefix>forFlyoutIsOpen,CmdBarFlyout,FlyoutPlacement,OverlayTeardownandFlyout: 0 failures each.dotnet test tests/Reactor.Tests --no-build -p:Platform=x64: passed, 15159 total, 0 failed, 64 skipped.dotnet restore Reactor.slnx, thendotnet build Reactor.slnx --no-restore -c Release: Build succeeded, 0 errors. The only warnings are the existingWIN2D0001. Locally, api.nuget.org TLS is blocked, so restore and the CLI's nested SignaturesGen restore used the user NuGet mirror (--configfile/RestoreConfigFile).ItemsView_Parking_*,Issue487_ScrollView*andReactorSource_LiveDialogPublished, and those fail identically withsrc/checked out atorigin/main. They are environmental (this desktop session) and unrelated.Risk / breaking changes
No public API change. The behaviour change is limited to
FlyoutElement.IsOpen, which now opens instead of throwing on Button/SplitButton targets. Attached-slot targets go throughShowAtinstead ofShowAttachedFlyout, which opens the same flyout on the same target.