Skip to content

Open Flyout IsOpen through ShowAt so Button targets don't throw - #1420

Merged
Alexandre Zollinger Chohfi (azchohfi) merged 5 commits into
mainfrom
azchohfi-fix-overlay-hosted-item-updates
Oct 28, 2026
Merged

Alexandre Zollinger Chohfi (azchohfi) merged 5 commits into
mainfrom
azchohfi-fix-overlay-hosted-item-updates

Conversation

@azchohfi

Copy link
Copy Markdown
Collaborator

Summary

Flyout(Button(...), ...) with { IsOpen = open } replaced the whole window with the render-error screen on setOpen(true) (and on mount with IsOpen = true). OverlayLifecycle opened the flyout with FlyoutBase.ShowAttachedFlyout(target), but SetFlyoutOnControl puts a Button/SplitButton target's flyout in the control's own Flyout property, so WinUI threw ArgumentException ("ShowAttached was called on an element without an attached FlyoutBase").

The fix opens through the installed flyout's ShowAt, using the ShowFlyoutWhenReady helper CommandBarFlyout already relies on (deferred to the target's Loaded at mount). The helper now takes the element-typed guard (IsFlyoutStillRequestingOpen for FlyoutElement), 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.IsOpen gets a doc comment matching CommandBarFlyoutElement.IsOpen: it is a one-shot open trigger (shown on mount and on the false → true edge), and setting it back to false does not close the flyout. That is unchanged behaviour. MenuFlyout has no IsOpen, and CommandBarFlyout already used ShowAt.

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

  • New selftest fixtures in 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, OnClosed resets the state, and a second rising edge re-opens it.
    • FlyoutIsOpen_ButtonTargetOnMount: IsOpen = true at mount.
    • FlyoutIsOpen_NonButtonTargetFromState: attached-slot positive control.
  • Mutation check: with the OverlayLifecycle change 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.
  • Unit tests for the new guard in tests/Reactor.Tests/FlyoutAttachmentTests.cs (FlyoutDeferredOpen_*).
  • dotnet run --project tests/Reactor.AppTests.Host --no-build -c Debug -p:Platform=x64 -- --self-test --filter <prefix> for FlyoutIsOpen, CmdBarFlyout, FlyoutPlacement, OverlayTeardown and Flyout: 0 failures each.
  • dotnet test tests/Reactor.Tests --no-build -p:Platform=x64: passed, 15159 total, 0 failed, 64 skipped.
  • dotnet restore Reactor.slnx, then dotnet build Reactor.slnx --no-restore -c Release: Build succeeded, 0 errors. The only warnings are the existing WIN2D0001. Locally, api.nuget.org TLS is blocked, so restore and the CLI's nested SignaturesGen restore used the user NuGet mirror (--configfile / RestoreConfigFile).
  • Full unfiltered selftest run (Debug, x64) on this machine. The only failures were in ItemsView_Parking_*, Issue487_ScrollView* and ReactorSource_LiveDialogPublished, and those fail identically with src/ checked out at origin/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 through ShowAt instead of ShowAttachedFlyout, which opens the same flyout on the same target.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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 IsOpen semantics 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

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build metrics

Artifact sizes for 4f7a5ff vs the base branch (8cdf4c1).

Packages (compressed .nupkg)

Artifact base PR Δ
Microsoft.UI.Reactor.nupkg 1.92 MB 1.92 MB +312 B (+0.02%) ≈
Microsoft.UI.Reactor.Advanced.nupkg 493.4 KB 493.4 KB -2 B (0.00%) ≈
Microsoft.UI.Reactor.Devtools.nupkg 287.9 KB 287.9 KB +1 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor

Artifact base PR Δ
Reactor.Analyzers.dll 411.5 KB 411.5 KB +0 B (0.00%) ≈
Reactor.dll 2.68 MB 2.68 MB +512 B (+0.02%) ≈
Reactor.Localization.Generator.dll 16.0 KB 16.0 KB +0 B (0.00%) ≈
Reactor.Wrappers.Abstractions.dll 10.5 KB 10.5 KB +0 B (0.00%) ≈
Reactor.Wrappers.Generator.dll 99.5 KB 99.5 KB +0 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor.Advanced

Artifact base PR Δ
Reactor.Advanced.dll 1.00 MB 1.00 MB +0 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor.Devtools

Artifact base PR Δ
Microsoft.UI.Reactor.Devtools.dll 787.5 KB 787.5 KB +0 B (0.00%) ≈

No size change beyond the noise floor. ✅

✅ smaller / ⚠️ larger / ≈ within noise. Sizes come from a Release dotnet pack on the CI runner: packages are the compressed .nupkg download size, assemblies the uncompressed DLL inside it.
workflow run.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🧪 Merged coverage

Coverage for 4f7a5ff vs the base branch (8cdf4c1) — unit + selftest merged.

Metric base PR Δ
Line 87.53% 87.53% 0.00 pp ≈
Branch 76.48% (979/1280) 76.48% (979/1280) 0.00 pp ≈

No coverage change beyond the noise floor. ✅

✅ higher / ⚠️ lower / ≈ within noise. Δ is in percentage points; coverage is unit + selftest merged (Debug x64) on the CI runner. Cobertura reports attached to the workflow run as artifacts.

@azchohfi Alexandre Zollinger Chohfi (azchohfi) added the agent-preparing Agent is addressing feedback or completing required validation and CI label Oct 27, 2026
…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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the Flyout opening changes.

No open issues 🎉

Review effort: Balanced

…hosted-item-updates

# Conflicts:
#	CHANGELOG.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the scoped Flyout opening fix.

No open issues 🎉

Review effort: Balanced

@azchohfi Alexandre Zollinger Chohfi (azchohfi) added ready-for-review Agent work and technical checks complete; awaiting review, not approval or merge and removed agent-preparing Agent is addressing feedback or completing required validation and CI labels Oct 27, 2026
…hosted-item-updates

# Conflicts:
#	CHANGELOG.md
@azchohfi Alexandre Zollinger Chohfi (azchohfi) added agent-preparing Agent is addressing feedback or completing required validation and CI and removed ready-for-review Agent work and technical checks complete; awaiting review, not approval or merge labels Oct 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the change to open attached Flyouts through ShowAt.

No open issues 🎉

Review effort: Balanced

@azchohfi Alexandre Zollinger Chohfi (azchohfi) added ready-for-review Agent work and technical checks complete; awaiting review, not approval or merge and removed agent-preparing Agent is addressing feedback or completing required validation and CI labels Oct 28, 2026
@azchohfi
Alexandre Zollinger Chohfi (azchohfi) merged commit 377ca2b into main Oct 28, 2026
65 of 66 checks passed
@azchohfi Alexandre Zollinger Chohfi (azchohfi) removed the ready-for-review Agent work and technical checks complete; awaiting review, not approval or merge label Oct 28, 2026
@azchohfi
Alexandre Zollinger Chohfi (azchohfi) deleted the azchohfi-fix-overlay-hosted-item-updates branch October 28, 2026 18:21
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.

[Bug] Opening a Flyout from state (IsOpen) replaces the window with a render error; SettingsExpander items never update

2 participants