Repository navigation
Fix IndicatorTemplate in IndicatorView does not update when set dynamically without initial value - #40133
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40133Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40133" |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
/rebase |
955a940 to
d18bae3
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Tests Failure Analysis
🧪 CI Analysis — click to expand📊 maui-prNo failures found. 🧪 maui-pr-devicetests
🧪 maui-pr-uitests
🧭 Follow-up — actions and refreshNext action: Inspect device termination, compare equivalent OS/handlers/screenshots, and restore missing diagnostics.
|
There was a problem hiding this comment.
🟡 Changes recommended
The new screenshot test lacks the baseline required by the iOS 18.5 CoreCLR lane, causing it to fail even when the template renders correctly.
2 open issues
What changed in this PR
Fixes #31128 by propagating dynamic IndicatorTemplate changes from the Controls layer to native IndicatorView handlers.
Changes:
- Notifies handlers when templates change and detaches old layout subscriptions.
- Updates platform handlers to replace templates and restore default indicators when cleared.
- Adds dynamic-template UI coverage and a Windows selection-color regression test.
| File | Description |
|---|---|
src/Core/tests/DeviceTests/Handlers/IndicatorView/IndicatorViewHandlerTests.Windows.cs |
Tests selection beyond the visible indicator limit. |
src/Core/src/Platform/Windows/MauiPageControl.cs |
Uses the visible index for selection colors. |
src/Core/src/Platform/iOS/UIPageControlExtensions.cs |
Adjusts single-page hiding for templates. |
src/Core/src/Platform/iOS/MauiPageControl.cs |
Manages template attachment, removal, and native indicator restoration. |
src/Core/src/Platform/Android/MauiPageControl.cs |
Adds braces around the existing shape-reset branch. |
src/Core/src/Handlers/IndicatorView/IndicatorViewHandler.Windows.cs |
Maps dynamic template changes and restores default indicators. |
src/Core/src/Handlers/IndicatorView/IndicatorViewHandler.Standard.cs |
Adds the standard-platform mapper stub. |
src/Core/src/Handlers/IndicatorView/IndicatorViewHandler.iOS.cs |
Maps template changes and refreshes single-page visibility. |
src/Core/src/Handlers/IndicatorView/IndicatorViewHandler.cs |
Registers the template-layout mapping. |
src/Core/src/Handlers/IndicatorView/IndicatorViewHandler.Android.cs |
Rebuilds indicators when the template changes. |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31128.cs |
Adds screenshot verification after dynamic template assignment. |
src/Controls/tests/TestCases.HostApp/Issues/Issue31128.cs |
Adds a reproduction page with an assignment button. |
src/Controls/src/Core/IndicatorView/IndicatorView.cs |
Notifies handlers, invalidates measurement, and detaches old subscriptions. |
Review effort: Balanced
| App.WaitForElement("AssignIndicatorTemplate"); | ||
| App.Tap("AssignIndicatorTemplate"); | ||
|
|
||
| VerifyScreenshot(); |
| => UpdateIndicatorLayout((IndicatorView)bindable, newValue), propertyChanged: (bindable, oldValue, newValue) => | ||
| { | ||
| var indicatorView = (IndicatorView)bindable; | ||
| indicatorView.Handler?.UpdateValue(nameof(ITemplatedIndicatorView.IndicatorsLayoutOverride)); |
This comment has been minimized.
This comment has been minimized.
| #if __IOS__ || MACCATALYST | ||
| [nameof(IView.FlowDirection)] = MapFlowDirection, | ||
| #endif | ||
| [nameof(ITemplatedIndicatorView.IndicatorsLayoutOverride)] = MapIndicatorsLayoutOverride |
There was a problem hiding this comment.
[major] Handler Mapper and Property Patterns - During initial handler setup, this mapping runs after IndicatorsShape even when IndicatorTemplate is null. Android removes and recreates the indicator children, and Windows replaces them through CreateIndicators(). An existing AppendToMapping(nameof(IIndicatorView.IndicatorsShape), ...) customization that sets those children's opacity or margins therefore executes but loses its changes before first display; previously those children survived the last indicator mapping. Neither rebuild reapplies the customized property mapping. Avoid rebuilding an already-untemplated control during initialization, and preserve property-mapper customizations when rebuilding.
| App.WaitForElement("AssignIndicatorTemplate"); | ||
| App.Tap("AssignIndicatorTemplate"); | ||
|
|
||
| VerifyScreenshot(); |
There was a problem hiding this comment.
[moderate] Regression Prevention and Test Coverage - The iOS baseline exists only under snapshots/ios-26. On iOS 18.5, VerifyScreenshot selects snapshots/ios, and VisualRegressionTester requires that exact environment's file without fallback. The frozen ui-tests.yml also explicitly selects 18.5 for the CoreCLR latest lane. Consequently this assertion fails with 'Baseline snapshot not yet created' even when the custom labels render correctly. Add the snapshots/ios baseline or assert the displayed custom labels directly.
| public void DynamicallyAssignedIndicatorTemplateDisplaysCustomLabels() | ||
| { | ||
| App.WaitForElement("AssignIndicatorTemplate"); | ||
| App.Tap("AssignIndicatorTemplate"); |
There was a problem hiding this comment.
[moderate] Regression Prevention and Test Coverage - This test stops after null-to-template assignment, so it cannot detect an old native template host surviving replacement or native dots failing to return after clearing IndicatorTemplate. Those replacement/restoration branches are added on Android, iOS/MacCatalyst and Windows, but the existing managed null-layout and weak-reference tests have no native handler, and the new Windows selection test never attaches a template. Add a distinct template A-to-B-to-null sequence asserting A disappears, B appears and native dots return on all four platforms. Include IndicatorSize=20, assign a template, reset size to 6, then clear it on iOS/MacCatalyst: the new size guard/cache reset intersects #35214 (fixed by #35215), while the existing native-only size-reset test misses that transition.
PR Test Gate
🧪 Gate analysis — click to expand✅ Passed. The selected verification satisfied the gate's passing conditions. Unmatched, skipped, or inconclusive groups are not passing evidence. 🖥 UI tests
Execution log excerptsWithout fix With fix PR head: 5ed10eca. Without-fix baseline: 331056d8. |
f28fd4f
into
dotnet:candidate/11.0.1xx-sr2
…ically without initial value (#40133) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Issue Details: When using IndicatorView, if the IndicatorTemplate property is not set initially and is assigned later, the new template is not applied on all platforms. ### Root cause: Changing IndicatorTemplate creates a managed layout, but doesn’t notify the native handler to display it. iOS/Windows only attached that layout during initial connection. ### Description of Changes: IndicatorView.cs now notifies the handler after the template updates and detaches the old layout’s event subscription. IndicatorViewHandler.cs now maps IndicatorsLayoutOverride, with platform implementations for dynamically switching templates and restoring default indicators when cleared. ### 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 #31128 <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> **Tested the behavior in the following platforms.** - [x] Android - [x] Windows - [x] iOS - [x] Mac | Before | After | |---------|--------| | **Android**<br> <video src="https://github.com/user-attachments/assets/47d726c9-2efb-44bf-a08d-9c8d8cde2d44" width="300" height="600"> | **Android**<br> <video src="https://github.com/user-attachments/assets/ca3979cd-4f21-4577-87f8-6b6b8963cc6a" width="300" height="600"> | Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
…ically without initial value (#40133) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Issue Details: When using IndicatorView, if the IndicatorTemplate property is not set initially and is assigned later, the new template is not applied on all platforms. ### Root cause: Changing IndicatorTemplate creates a managed layout, but doesn’t notify the native handler to display it. iOS/Windows only attached that layout during initial connection. ### Description of Changes: IndicatorView.cs now notifies the handler after the template updates and detaches the old layout’s event subscription. IndicatorViewHandler.cs now maps IndicatorsLayoutOverride, with platform implementations for dynamically switching templates and restoring default indicators when cleared. ### 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 #31128 <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> **Tested the behavior in the following platforms.** - [x] Android - [x] Windows - [x] iOS - [x] Mac | Before | After | |---------|--------| | **Android**<br> <video src="https://github.com/user-attachments/assets/47d726c9-2efb-44bf-a08d-9c8d8cde2d44" width="300" height="600"> | **Android**<br> <video src="https://github.com/user-attachments/assets/ca3979cd-4f21-4577-87f8-6b6b8963cc6a" width="300" height="600"> | Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
…ically without initial value (#40133) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Issue Details: When using IndicatorView, if the IndicatorTemplate property is not set initially and is assigned later, the new template is not applied on all platforms. ### Root cause: Changing IndicatorTemplate creates a managed layout, but doesn’t notify the native handler to display it. iOS/Windows only attached that layout during initial connection. ### Description of Changes: IndicatorView.cs now notifies the handler after the template updates and detaches the old layout’s event subscription. IndicatorViewHandler.cs now maps IndicatorsLayoutOverride, with platform implementations for dynamically switching templates and restoring default indicators when cleared. ### 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 #31128 <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> **Tested the behavior in the following platforms.** - [x] Android - [x] Windows - [x] iOS - [x] Mac | Before | After | |---------|--------| | **Android**<br> <video src="https://github.com/user-attachments/assets/47d726c9-2efb-44bf-a08d-9c8d8cde2d44" width="300" height="600"> | **Android**<br> <video src="https://github.com/user-attachments/assets/ca3979cd-4f21-4577-87f8-6b6b8963cc6a" width="300" height="600"> | Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
…ically without initial value (dotnet#40133) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Issue Details: When using IndicatorView, if the IndicatorTemplate property is not set initially and is assigned later, the new template is not applied on all platforms. ### Root cause: Changing IndicatorTemplate creates a managed layout, but doesn’t notify the native handler to display it. iOS/Windows only attached that layout during initial connection. ### Description of Changes: IndicatorView.cs now notifies the handler after the template updates and detaches the old layout’s event subscription. IndicatorViewHandler.cs now maps IndicatorsLayoutOverride, with platform implementations for dynamically switching templates and restoring default indicators when cleared. ### 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 dotnet#31128 <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> **Tested the behavior in the following platforms.** - [x] Android - [x] Windows - [x] iOS - [x] Mac | Before | After | |---------|--------| | **Android**<br> <video src="https://github.com/user-attachments/assets/47d726c9-2efb-44bf-a08d-9c8d8cde2d44" width="300" height="600"> | **Android**<br> <video src="https://github.com/user-attachments/assets/ca3979cd-4f21-4577-87f8-6b6b8963cc6a" width="300" height="600"> | Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>


Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issue Details:
When using IndicatorView, if the IndicatorTemplate property is not set initially and is assigned later, the new template is not applied on all platforms.
Root cause:
Changing IndicatorTemplate creates a managed layout, but doesn’t notify the native handler to display it. iOS/Windows only attached that layout during initial connection.
Description of Changes:
IndicatorView.cs now notifies the handler after the template updates and detaches the old layout’s event subscription.
IndicatorViewHandler.cs now maps IndicatorsLayoutOverride, with platform implementations for dynamically switching templates and restoring default indicators when cleared.
Issues Fixed
Fixes #31128
Tested the behavior in the following platforms.
Before-31128.mov
After-31128.mov