Fix Align measure to respect explicitly set width#2101
Merged
patriksvensson merged 2 commits intospectreconsole:mainfrom Apr 25, 2026
Merged
Fix Align measure to respect explicitly set width#2101patriksvensson merged 2 commits intospectreconsole:mainfrom
patriksvensson merged 2 commits intospectreconsole:mainfrom
Conversation
Contributor
Author
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
Fixes Align measurement behavior so an explicitly set Align.Width is respected during layout/measurement (not just during rendering), addressing issue #1910 where containers like Panel could expand unexpectedly.
Changes:
- Add
Align.Measureoverride that clamps toWidthwhen provided. - Add a unit test intended to prevent regressions around explicit width handling.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Spectre.Console/Widgets/Align.cs | Overrides Measure to respect explicitly set Width when reporting max width. |
| src/Spectre.Console.Tests/Unit/Widgets/AlignTests.cs | Adds a test intended to validate explicit width behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
067ef56 to
e40d862
Compare
e40d862 to
5b66030
Compare
Contributor
|
Added a commit to this PR that makes the build pass. |
patriksvensson
approved these changes
Apr 25, 2026
Contributor
|
Merged! Thank you for your contribution. Much appreciated! 👍 |
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.
Fixes #1910
Changes
Aligndid not override theMeasuremethod, causing it to always returnmaxWidthregardless of any explicitly setWidth.Added a
Measureoverride that respects the explicitly set width, consistent with howRenderalready handles it.Added regression test to ensure explicit width is enforced.
Please upvote 👍 this pull request if you are interested in it.