-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Windows] Fix TitleBar.IsVisible = false the caption buttons become unresponsive #33256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
PureWeen
merged 7 commits into
dotnet:inflight/current
from
devanathan-vaithiyanathan:fix-33171
Jan 27, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
490ab7f
fix added
devanathan-vaithiyanathan c0d3db5
simplified the fix
devanathan-vaithiyanathan 2a04cd3
Test added
devanathan-vaithiyanathan 4952bb8
Test added
devanathan-vaithiyanathan f4b98c3
logic modified
devanathan-vaithiyanathan 5ac4bd5
Update Issue33171.cs
devanathan-vaithiyanathan a7ac702
Optimize UpdateTitleBarContentSize for better performance
PureWeen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
120 changes: 120 additions & 0 deletions
120
src/Controls/tests/TestCases.HostApp/Issues/Issue33171.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 33171, "When TitleBar.IsVisible = false the caption buttons become unresponsive on Windows", PlatformAffected.UWP)] | ||
| public class Issue33171 : ContentPage | ||
| { | ||
| TitleBar titleBar; | ||
|
|
||
| public Issue33171() | ||
| { | ||
| Title = "Issue 33171"; | ||
|
|
||
| // Create TitleBar | ||
| titleBar = new TitleBar | ||
| { | ||
| Title = "Maui App", | ||
| Subtitle = "Hello, World!", | ||
| ForegroundColor = Colors.Red, | ||
| HeightRequest = 48 | ||
| }; | ||
|
|
||
| titleBar.LeadingContent = new Image {Source = "dotnet_bot.png", HeightRequest = 24}; | ||
|
|
||
| titleBar.Content = new SearchBar | ||
| { | ||
| Placeholder = "Search", | ||
| PlaceholderColor = Colors.White, | ||
| MaximumWidthRequest = 300, | ||
| HorizontalOptions = LayoutOptions.Fill, | ||
| VerticalOptions = LayoutOptions.Center | ||
| }; | ||
|
|
||
| // Set the TitleBar on the current Window when this page appears | ||
| this.Loaded += (sender, e) => | ||
| { | ||
| if (Window != null) | ||
| { | ||
| Window.TitleBar = titleBar; | ||
| } | ||
| }; | ||
|
|
||
| // Create a label to display window size | ||
| var windowSizeLabel = new Label | ||
| { | ||
| AutomationId = "WindowSizeLabel", | ||
| FontSize = 16, | ||
| HorizontalOptions = LayoutOptions.Center | ||
| }; | ||
|
|
||
| // Create a button to reduce window width | ||
| var reduceWidthButton = new Button | ||
| { | ||
| Text = "Reduce Window Width", | ||
| AutomationId = "ReduceWidthButton", | ||
| }; | ||
|
|
||
| var changeVisibility = new Button | ||
| { | ||
| Text = "Toggle", | ||
| AutomationId = "ToggleTitleBarVisibilityButton", | ||
| }; | ||
|
|
||
| var getStatus = new Button | ||
| { | ||
| Text = "Get Status", | ||
| AutomationId = "GetStatusButton", | ||
| }; | ||
|
|
||
| getStatus.Clicked += (sender, e) => | ||
| { | ||
| if (Window != null) | ||
| { | ||
| windowSizeLabel.Text = Window.Width.ToString(); | ||
| } | ||
| }; | ||
|
|
||
| changeVisibility.Clicked += (sender, e) => | ||
| { | ||
| if (Window != null && Window.TitleBar != null) | ||
| { | ||
| titleBar.IsVisible = !titleBar.IsVisible; | ||
| } | ||
| }; | ||
|
|
||
|
|
||
| reduceWidthButton.Clicked += (sender, e) => | ||
| { | ||
| if (Window != null) | ||
| { | ||
| var currentWidth = Window.Width; | ||
| var newWidth = Window.Width/2; | ||
| Window.Width = newWidth; | ||
| Window.Height = Window.Height / 2; | ||
|
|
||
| windowSizeLabel.Text = Window.Width.ToString(); | ||
| } | ||
| }; | ||
|
|
||
| // Create the page content with a Label | ||
| Content = new VerticalStackLayout | ||
| { | ||
| Spacing = 25, | ||
| Padding = new Thickness(30), | ||
| VerticalOptions = LayoutOptions.Center, | ||
| Children = | ||
| { | ||
| new Label | ||
| { | ||
| Text = "TitleBar Visibility Test", | ||
| AutomationId = "TitleBarAlignmentLabel", | ||
| FontSize = 32, | ||
| HorizontalOptions = LayoutOptions.Center | ||
| }, | ||
| windowSizeLabel, | ||
| changeVisibility, | ||
| getStatus, | ||
| reduceWidthButton, | ||
| } | ||
| }; | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33171.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #if WINDOWS //This issue is Windows specific | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue33171 : _IssuesUITest | ||
| { | ||
| public override string Issue => "When TitleBar.IsVisible = false the caption buttons become unresponsive on Windows"; | ||
|
|
||
| public Issue33171(TestDevice device) : base(device) { } | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Window)] | ||
| public void TitleBarCaptionButtonsResponsiveWhenIsVisibleFalse() | ||
| { | ||
| App.WaitForElement("ToggleTitleBarVisibilityButton"); | ||
| App.Tap("ToggleTitleBarVisibilityButton"); | ||
| App.Tap("ReduceWidthButton"); | ||
| var windowSize = App.FindElement("WindowSizeLabel").GetText(); | ||
| App.TapMaximizeButton(); | ||
| App.Tap("GetStatusButton"); | ||
| var newWindowSize = App.FindElement("WindowSizeLabel").GetText(); | ||
| Assert.That(newWindowSize, Is.Not.EqualTo(windowSize), "Window size should change after maximizing the window."); | ||
| } | ||
| } | ||
| #endif | ||
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test verifies that the maximize button works after toggling TitleBar visibility and reducing window width. However, the PR description states that caption buttons become unresponsive "after resizing the window". The test should verify this specific scenario by:
The current test flow doesn't clearly demonstrate the bug scenario described in the PR - it toggles visibility, reduces width, maximizes, and checks the size change. Consider adding a more explicit test that demonstrates caption buttons are responsive after window resize with TitleBar.IsVisible = false.