Skip to content

Fix a crash when a control moves to another top level during layout - #22491

Merged
MrJul merged 2 commits into
AvaloniaUI:mainfrom
Evan260:fix-commandbar-resize-crash
Oct 21, 2026
Merged

MrJul merged 2 commits into
AvaloniaUI:mainfrom
Evan260:fix-commandbar-resize-crash

Conversation

@Evan260

@Evan260 Evan260 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

What does the pull request do?

Stops the app crashing when a CommandBar with its overflow menu open is resized smaller.

What is the current behavior?

With the overflow open and sticky, and no width set on the bar, shrinking the window crashes the app as soon as a primary command has to move into the overflow:

System.ArgumentException: Attempt to call InvalidateArrange on wrong LayoutManager.
   at Avalonia.Layout.LayoutManager.InvalidateArrange(Layoutable control)
   at Avalonia.Layout.LayoutManager.ExecuteArrangePass()
   at Avalonia.Layout.LayoutManager.InnerLayoutPass()
   at Avalonia.Layout.LayoutManager.ExecuteLayoutPass()
   at Avalonia.Controls.WindowBase.HandleResized(Size clientSize, WindowResizeReason reason)

What is the updated/expected behavior with this PR?

The window resizes and the commands move into the open overflow menu.

Fixed issues

Fixes #22476

@github-actions

Copy link
Copy Markdown

NuGet packages

The packages for this pull request have been published (workflow run):

@MrJul MrJul added bug backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Oct 16, 2026
@MrJul
MrJul added this pull request to the merge queue Oct 21, 2026
Merged via the queue into AvaloniaUI:main with commit 26b4ed5 Oct 21, 2026
12 checks passed
@Evan260
Evan260 deleted the fix-commandbar-resize-crash branch October 21, 2026 17:40
MrJul pushed a commit that referenced this pull request Nov 2, 2026
…22491)

* Add test

* Keep the layout pass off controls that moved to another window
@MrJul MrJul added backported-12.1.x and removed backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CommandBar crashes the app under certain conditions.

3 participants