[Windows] Fix TitleBar.IsVisible = false the caption buttons become unresponsive#33256
Conversation
|
/rebase |
5eec4c2 to
1f7eb21
Compare
There was a problem hiding this comment.
Pull request overview
This pull request fixes a Windows-specific issue where system caption buttons (minimize, maximize, close) become unresponsive after resizing the window when TitleBar.IsVisible is set to false.
Key Changes
- Updated
WindowRootView.UpdateTitleBarContentSize()to conditionally apply passthrough regions based on TitleBar visibility - Added Windows-specific UI test helper methods to interact with system caption buttons via Appium
- Created comprehensive UI test to verify caption button responsiveness when TitleBar is hidden
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Core/src/Platform/Windows/WindowRootView.cs |
Added visibility check to only set passthrough regions when TitleBar is visible, and clear them when hidden to prevent blocking caption buttons |
src/TestUtils/src/UITest.Appium/HelperExtensions.cs |
Added TapMinimizeButton(), TapMaximizeButton(), and FindSystemButton() helper methods for Windows UI automation testing of system caption buttons |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33171.cs |
Created Windows-specific NUnit test that verifies caption buttons remain responsive when TitleBar visibility is toggled and window is resized |
src/Controls/tests/TestCases.HostApp/Issues/Issue33171.cs |
Created test page with TitleBar, visibility toggle button, window resize button, and window size label to reproduce and test the issue |
| 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."); | ||
| } |
There was a problem hiding this comment.
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:
- Setting TitleBar.IsVisible = false
- Resizing the window (currently done via ReduceWidthButton)
- Attempting to click caption buttons to verify they are responsive
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.
|
LGTM, thanks! |
|
/rebase |
1f7eb21 to
f50b903
Compare
|
/rebase |
f50b903 to
5ac4bd5
Compare
Code Review - Suggested SimplificationsAfter testing multiple alternative approaches and having 4 different AI models evaluate the implementation, all models unanimously identified two optimization opportunities in the current fix. ✅ Current Implementation: CORRECTThe fix successfully solves the caption button responsiveness issue. However, it can be simplified for better performance and clarity. 🔴 Issue #1: Duplicate Visibility CheckCurrent code checks visibility twice:
Suggested: Cache the visibility check once at the start: bool isTitleBarVisible = AppTitleBarContentControl.Visibility == UI.Xaml.Visibility.Visible;🔴 Issue #2: Unnecessary Loop Execution (Performance)Current code (lines 217-225) always executes the loop even when title bar is hidden: The code performs expensive Suggested: Gate the loop behind the visibility check: if (isTitleBarVisible && PassthroughTitlebarElements.Count > 0)
{
// Only calculate rects when actually needed
var rectArray = new List<Rect32>();
foreach (var child in PassthroughTitlebarElements)
{
// ... expensive calculations ...
}
nonClientInputSrc.SetRegionRects(...);
}
else
{
nonClientInputSrc.ClearRegionRects(...);
}💡 Recommended RefactorClick to see full optimized implementationinternal void UpdateTitleBarContentSize()
{
if (AppTitleBarContentControl is null)
return;
// Cache visibility check (fixes issue #1)
bool isTitleBarVisible = AppTitleBarContentControl.Visibility == UI.Xaml.Visibility.Visible;
// Update height logic
if (isTitleBarVisible && _appTitleBarHeight != AppTitleBarContentControl.ActualHeight)
{
UpdateRootNavigationViewMargins(AppTitleBarContentControl.ActualHeight);
if (AppWindowId.HasValue)
{
AppWindow.GetFromWindowId(AppWindowId.Value).TitleBar.PreferredHeightOption =
_appTitleBarHeight >= 48 ? TitleBarHeightOption.Tall : TitleBarHeightOption.Standard;
}
this.RefreshThemeResources();
}
// Update passthrough regions
if (AppWindowId.HasValue)
{
var nonClientInputSrc = InputNonClientPointerSource.GetForWindowId(AppWindowId.Value);
// Only calculate rects when needed (fixes issue #2)
if (isTitleBarVisible && PassthroughTitlebarElements.Count > 0)
{
var rectArray = new List<Rect32>();
foreach (var child in PassthroughTitlebarElements)
{
var transform = child.TransformToVisual(null);
var bounds = transform.TransformBounds(
new FRect(0, 0, child.ActualWidth, child.ActualHeight));
rectArray.Add(GetRect(bounds, XamlRoot.RasterizationScale));
}
nonClientInputSrc.SetRegionRects(NonClientRegionKind.Passthrough, [.. rectArray]);
}
else
{
nonClientInputSrc.ClearRegionRects(NonClientRegionKind.Passthrough);
}
}
}📊 Benefits
🤖 Model Agreement (4/4 Consensus)All models (Claude Sonnet, Claude Opus, Gemini, GPT-5.2 Codex) identified these exact same issues and suggested identical fixes. Verdict: Current implementation is correct and solves the bug, but the suggested refactor improves performance and clarity without changing behavior. |
Cache visibility check to avoid duplicate property access and gate the expensive TransformToVisual loop behind visibility check to avoid unnecessary calculations when title bar is hidden. Based on unanimous feedback from 4 AI models (Claude Sonnet, Claude Opus, Gemini, GPT-5.2 Codex) during code review.
|
/azp run |
|
@devanathan-vaithiyanathan let me know if my last commit is alright and you agree with the changes |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Yes @PureWeen , changes are fine |
…nresponsive (#33256) <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details On Windows, when TitleBar.IsVisible is set to false, the system caption buttons (minimize, maximize, close) become unresponsive after resizing the window. ### Description of Change <!-- Enter description of the fix in this section --> Updated WindowRootView.UpdateTitleBarContentSize() to apply passthrough regions only when the TitleBar is visible and to clear them when it is hidden, preventing stale regions from blocking caption button interactions. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #33171 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> **Tested the behavior in the following platforms.** - [ ] Android - [x] Windows - [ ] iOS - [ ] Mac | Before | After | |---------|--------| | **Windows**<br> <video src="https://github.com/user-attachments/assets/6b30d580-ea49-4b5d-9e4c-f6db75897d5d" width="600" height="300"> | **Windows**<br> <video src="https://github.com/user-attachments/assets/52f04718-3f2e-4d5e-985b-72efac175af7" width="600" height="300"> | --------- Co-authored-by: Shane Neuville <shane94@hotmail.com>
…nresponsive (#33256) <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details On Windows, when TitleBar.IsVisible is set to false, the system caption buttons (minimize, maximize, close) become unresponsive after resizing the window. ### Description of Change <!-- Enter description of the fix in this section --> Updated WindowRootView.UpdateTitleBarContentSize() to apply passthrough regions only when the TitleBar is visible and to clear them when it is hidden, preventing stale regions from blocking caption button interactions. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #33171 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> **Tested the behavior in the following platforms.** - [ ] Android - [x] Windows - [ ] iOS - [ ] Mac | Before | After | |---------|--------| | **Windows**<br> <video src="https://github.com/user-attachments/assets/6b30d580-ea49-4b5d-9e4c-f6db75897d5d" width="600" height="300"> | **Windows**<br> <video src="https://github.com/user-attachments/assets/52f04718-3f2e-4d5e-985b-72efac175af7" width="600" height="300"> | --------- Co-authored-by: Shane Neuville <shane94@hotmail.com>
…nresponsive (#33256) <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details On Windows, when TitleBar.IsVisible is set to false, the system caption buttons (minimize, maximize, close) become unresponsive after resizing the window. ### Description of Change <!-- Enter description of the fix in this section --> Updated WindowRootView.UpdateTitleBarContentSize() to apply passthrough regions only when the TitleBar is visible and to clear them when it is hidden, preventing stale regions from blocking caption button interactions. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #33171 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> **Tested the behavior in the following platforms.** - [ ] Android - [x] Windows - [ ] iOS - [ ] Mac | Before | After | |---------|--------| | **Windows**<br> <video src="https://github.com/user-attachments/assets/6b30d580-ea49-4b5d-9e4c-f6db75897d5d" width="600" height="300"> | **Windows**<br> <video src="https://github.com/user-attachments/assets/52f04718-3f2e-4d5e-985b-72efac175af7" width="600" height="300"> | --------- Co-authored-by: Shane Neuville <shane94@hotmail.com>
…nresponsive (#33256) <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details On Windows, when TitleBar.IsVisible is set to false, the system caption buttons (minimize, maximize, close) become unresponsive after resizing the window. ### Description of Change <!-- Enter description of the fix in this section --> Updated WindowRootView.UpdateTitleBarContentSize() to apply passthrough regions only when the TitleBar is visible and to clear them when it is hidden, preventing stale regions from blocking caption button interactions. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #33171 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> **Tested the behavior in the following platforms.** - [ ] Android - [x] Windows - [ ] iOS - [ ] Mac | Before | After | |---------|--------| | **Windows**<br> <video src="https://github.com/user-attachments/assets/6b30d580-ea49-4b5d-9e4c-f6db75897d5d" width="600" height="300"> | **Windows**<br> <video src="https://github.com/user-attachments/assets/52f04718-3f2e-4d5e-985b-72efac175af7" width="600" height="300"> | --------- Co-authored-by: Shane Neuville <shane94@hotmail.com>
…nresponsive (#33256) <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details On Windows, when TitleBar.IsVisible is set to false, the system caption buttons (minimize, maximize, close) become unresponsive after resizing the window. ### Description of Change <!-- Enter description of the fix in this section --> Updated WindowRootView.UpdateTitleBarContentSize() to apply passthrough regions only when the TitleBar is visible and to clear them when it is hidden, preventing stale regions from blocking caption button interactions. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #33171 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> **Tested the behavior in the following platforms.** - [ ] Android - [x] Windows - [ ] iOS - [ ] Mac | Before | After | |---------|--------| | **Windows**<br> <video src="https://github.com/user-attachments/assets/6b30d580-ea49-4b5d-9e4c-f6db75897d5d" width="600" height="300"> | **Windows**<br> <video src="https://github.com/user-attachments/assets/52f04718-3f2e-4d5e-985b-72efac175af7" width="600" height="300"> | --------- Co-authored-by: Shane Neuville <shane94@hotmail.com>
…nresponsive (#33256) <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details On Windows, when TitleBar.IsVisible is set to false, the system caption buttons (minimize, maximize, close) become unresponsive after resizing the window. ### Description of Change <!-- Enter description of the fix in this section --> Updated WindowRootView.UpdateTitleBarContentSize() to apply passthrough regions only when the TitleBar is visible and to clear them when it is hidden, preventing stale regions from blocking caption button interactions. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #33171 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> **Tested the behavior in the following platforms.** - [ ] Android - [x] Windows - [ ] iOS - [ ] Mac | Before | After | |---------|--------| | **Windows**<br> <video src="https://github.com/user-attachments/assets/6b30d580-ea49-4b5d-9e4c-f6db75897d5d" width="600" height="300"> | **Windows**<br> <video src="https://github.com/user-attachments/assets/52f04718-3f2e-4d5e-985b-72efac175af7" width="600" height="300"> | --------- Co-authored-by: Shane Neuville <shane94@hotmail.com>
…nresponsive (#33256) <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details On Windows, when TitleBar.IsVisible is set to false, the system caption buttons (minimize, maximize, close) become unresponsive after resizing the window. ### Description of Change <!-- Enter description of the fix in this section --> Updated WindowRootView.UpdateTitleBarContentSize() to apply passthrough regions only when the TitleBar is visible and to clear them when it is hidden, preventing stale regions from blocking caption button interactions. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #33171 <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> **Tested the behavior in the following platforms.** - [ ] Android - [x] Windows - [ ] iOS - [ ] Mac | Before | After | |---------|--------| | **Windows**<br> <video src="https://github.com/user-attachments/assets/6b30d580-ea49-4b5d-9e4c-f6db75897d5d" width="600" height="300"> | **Windows**<br> <video src="https://github.com/user-attachments/assets/52f04718-3f2e-4d5e-985b-72efac175af7" width="600" height="300"> | --------- Co-authored-by: Shane Neuville <shane94@hotmail.com>
.NET MAUI inflight/candidate introduces significant improvements across all platforms with focus on quality, performance, and developer experience. This release includes 20 commits with various improvements, bug fixes, and enhancements. ## Blazor - Fix for BlazorWebView Back Navigation Issues on Android 13+ After Predictive Back Gesture Changes by @SuthiYuvaraj in #33213 <details> <summary>🔧 Fixes</summary> - [Back navigation different between .net 9 and .net 10 blazor hybrid](#32767) </details> ## CollectionView - [Android] Fix for CollectionView.EmptyView does not remeasure its height when the parent layout changes dynamically, causing incorrect sizing. by @BagavathiPerumal in #33559 <details> <summary>🔧 Fixes</summary> - [`CollectionView.EmptyView` does not remeasure its height when the parent layout changes dynamically, causing incorrect sizing.](#33324) </details> - [Android] Fixed CollectionView reordering last item by @vitalii-vov in #17825 <details> <summary>🔧 Fixes</summary> - [Android app crashes when dragging into CollectionView](#17823) </details> ## DateTimePicker - [iOS] Fix VoiceOver focus not shifting to Picker/DatePicker/TimePicker popups by @kubaflo in #33152 <details> <summary>🔧 Fixes</summary> - [Voiceover does not automatically shift focus to the "Category" popup when it opens.: A11y_Developer balance version .NET 10_Project_ScreenReader](#30746) </details> ## Dialogalert - [iOS 26] Fix DisplayPromptAsync maxLength not enforced due to new multi-range delegate by @Shalini-Ashokan in #33616 <details> <summary>🔧 Fixes</summary> - [[iOS 26.1] DisplayPromptAsync ignores maxLength and does not respect RTL FlowDirection](#33549) </details> ## Flyout - [iOS] Shell: Account for SafeArea when positioning flyout footer by @kubaflo in #32891 <details> <summary>🔧 Fixes</summary> - [[IOS] Footer not displaying in iOS when StackOrientation.Horizontal is set on FlyoutFooter](#26395) </details> ## Fonts - Hide obsolete FontSize values from IDE autocomplete by @noiseonwires in #33694 ## Gestures - Android pan fixes by @BurningLights in #21547 <details> <summary>🔧 Fixes</summary> - [Flickering occurs while updating the width of ContentView through PanGestureRecognizer.](#20772) </details> ## Navigation - Shell: Add duplicate route validation for sibling elements by @SubhikshaSf4851 in #32296 <details> <summary>🔧 Fixes</summary> - [OnNavigatedTo is not called when navigating from a specific page](#14000) </details> ## Picker - Improved Unfocus support for Picker on Mac Catalyst by @kubaflo in #33127 <details> <summary>🔧 Fixes</summary> - [When using voiceover unable to access expanded list of project combo box: A11y_.NET maui_user can creat a tak_Screen reader](#30897) - [Task and Project controls are not accessible with keyboard:A11y_.NET maui_User can create a new task_Keyboard](#30891) </details> ## SafeArea - [iOS] SafeArea: Return Empty for non-ISafeAreaView views (opt-in model) by @praveenkumarkarunanithi in #33526 <details> <summary>🔧 Fixes</summary> - [[iOS] SafeArea is not applied when a ContentPage uses a ControlTemplate](#33458) </details> ## Shell - [iOS] Fix ObjectDisposedException in TraitCollectionDidChange on window disposal by @jeremy-visionaid in #33353 <details> <summary>🔧 Fixes</summary> - [Intermittent crash on exit on MacCatalyst - ObjectDisposedException](#33352) </details> - [Issue-Resolver] Explicit fallback for BackButtonBehavior lookup by @kubaflo in #33204 <details> <summary>🔧 Fixes</summary> - [Setting BackButtonBehavior to not visible or not enabled does not work](#28570) - [BackButtonBehavior not bound](#33139) </details> ## Templates - [Templates] Remove redundant SemanticProperties.Description attribute by @kubaflo in #33621 <details> <summary>🔧 Fixes</summary> - [Task and Project controls are not accessible with keyboard:A11y_.NET maui_User can create a new task_Keyboard](#30891) - [Unable to select "Tags" when Voiceover is turned on.: A11y_Developer balance version .NET 10_Project_ScreenReader](#30749) </details> ## Theme - [Windows] Fix runtime theme update for controls and TitleBar by @Tamilarasan-Paranthaman in #31714 <details> <summary>🔧 Fixes</summary> - [[Windows][MacOS?] Change title bar color when switching light/dark theme at runtime](#12507) - [OS system components ignore app theme](#22058) - [[Mac Catalyst][Windows] TitleBar not reacting on UserAppTheme changes](#30518) - [In dark theme "Back" and "hamburger" button icon color contrast with background color is less than 3:1: A11y_.NET maui_User can get all the insights of Dashboard_Non text Contrast](#30807) - [`Switch` is invisible on `PointOver` when theme has changed](#31819) </details> ## Theming - [XSG] Fix Style Setters referencing source-generated bindable properties by @simonrozsival in #33562 ## Titlebar - [Windows] Fix TitleBar.IsVisible = false the caption buttons become unresponsive by @devanathan-vaithiyanathan in #33256 <details> <summary>🔧 Fixes</summary> - [When TitleBar.IsVisible = false the caption buttons become unresponsive on Windows](#33171) </details> ## WebView - Fix WebView JavaScript string escaping for backslashes and quotes by @StephaneDelcroix in #33726 ## Xaml - [XSG] Fix NaN value in XAML generating invalid code by @StephaneDelcroix in #33533 <details> <summary>🔧 Fixes</summary> - [[XSG] NaN value in XAML generates invalid code](#33532) </details> <details> <summary>📦 Other (1)</summary> - Remove InternalsVisibleTo attributes for .NET MAUI Community Toolkit by @jfversluis via @Copilot in #33442 </details> **Full Changelog**: main...inflight/candidate
Issue Details
On Windows, when TitleBar.IsVisible is set to false, the system caption buttons (minimize, maximize, close) become unresponsive after resizing the window.
Description of Change
Updated WindowRootView.UpdateTitleBarContentSize() to apply passthrough regions only when the TitleBar is visible and to clear them when it is hidden, preventing stale regions from blocking caption button interactions.
Issues Fixed
Fixes #33171
Tested the behavior in the following platforms.
After.mov
Before.mov