Repository navigation
[iOS/MacCatalyst] DatePicker and TimePicker Background is not cleared when set to null at runtime - #36934
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 36934Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 36934" |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
|
Hey there @@HarishwaranVijayakumar! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
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.
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
kubaflo
left a comment
There was a problem hiding this comment.
Looks like some test failures are related - could you please check?
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 18 changed files in this pull request and generated no new comments.
Suppressed comments (3)
src/Core/src/Handlers/TimePicker/TimePickerHandler.cs:23
- MacCatalyst builds likely won't execute this new Background mapper because the preprocessor condition excludes MACCATALYST. That means the new MapBackground implementation in TimePickerHandler.MacCatalyst.cs won't be used and the issue can remain on MacCatalyst.
#if IOS || ANDROID || WINDOWS
[nameof(ITimePicker.Background)] = MapBackground,
#endif
src/Core/src/Handlers/DatePicker/DatePickerHandler.cs:30
- The Background mapper is only enabled for ANDROID/WINDOWS and IOS. On MacCatalyst this will fall back to ViewHandler.ViewMapper, so the new MapBackground implementation in DatePickerHandler.MacCatalyst.cs won’t run and the background may still not clear at runtime.
#if ANDROID || WINDOWS
[nameof(IDatePicker.Background)] = MapBackground,
#elif IOS
[nameof(IDatePicker.Background)] = MapBackground,
[nameof(IDatePicker.FlowDirection)] = MapFlowDirection,
#endif
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue36933.cs:20
- The test only waits for the DatePicker, but the screenshots also validate the TimePicker’s background. Waiting for the TimePicker element as well will reduce screenshot flakiness/race conditions on slower devices.
App.WaitForElement("TestDatePicker");
I checked the CI failures, and they are not related. |
… when set to null at runtime (#36934) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details: - DatePicker and TimePicker Background set to null at runtime does not clear the background on iOS and MacCatalyst. The previously set background color/brush remains visible. ### Root Cause of the issue: - On iOS, ViewExtensions.UpdateBackground() has a type guard (line 84-89) that only clears BackgroundColor for LayoutView or ContentView when paint is null — for all other UIView subclasses (including UITextField/UIDatePicker used by DatePicker/TimePicker), it early-returns without clearing. DatePicker and TimePicker didn't have their own MapBackground registered for iOS/MacCatalyst (only Android/Windows had it), so they fell through to this broken path. ### Description of Change **Platform handler updates:** * Added internal `MapBackground` methods to both `DatePickerHandler` and `TimePickerHandler` for iOS and MacCatalyst, which remove the background layer and reset the background color when the `Background` property is set to `null`. * Updated property mappers in `DatePickerHandler.cs` and `TimePickerHandler.cs` to include the new `MapBackground` mapping for iOS and MacCatalyst. **Test coverage:** * Added a new test case page (`Issue36933`) that allows toggling the background of `DatePicker` and `TimePicker` between a color and `null` at runtime. * Added a UI test verifying that the background is cleared when set to `null` and can be set to a new color. **Code maintenance:** * Added missing `using Microsoft.Maui.Graphics;` directives to relevant files for background color handling. ### 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 #36933 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [x] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2"> | <video src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
… when set to null at runtime (#36934) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details: - DatePicker and TimePicker Background set to null at runtime does not clear the background on iOS and MacCatalyst. The previously set background color/brush remains visible. ### Root Cause of the issue: - On iOS, ViewExtensions.UpdateBackground() has a type guard (line 84-89) that only clears BackgroundColor for LayoutView or ContentView when paint is null — for all other UIView subclasses (including UITextField/UIDatePicker used by DatePicker/TimePicker), it early-returns without clearing. DatePicker and TimePicker didn't have their own MapBackground registered for iOS/MacCatalyst (only Android/Windows had it), so they fell through to this broken path. ### Description of Change **Platform handler updates:** * Added internal `MapBackground` methods to both `DatePickerHandler` and `TimePickerHandler` for iOS and MacCatalyst, which remove the background layer and reset the background color when the `Background` property is set to `null`. * Updated property mappers in `DatePickerHandler.cs` and `TimePickerHandler.cs` to include the new `MapBackground` mapping for iOS and MacCatalyst. **Test coverage:** * Added a new test case page (`Issue36933`) that allows toggling the background of `DatePicker` and `TimePicker` between a color and `null` at runtime. * Added a UI test verifying that the background is cleared when set to `null` and can be set to a new color. **Code maintenance:** * Added missing `using Microsoft.Maui.Graphics;` directives to relevant files for background color handling. ### 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 #36933 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [x] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2"> | <video src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
… when set to null at runtime (#36934) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details: - DatePicker and TimePicker Background set to null at runtime does not clear the background on iOS and MacCatalyst. The previously set background color/brush remains visible. ### Root Cause of the issue: - On iOS, ViewExtensions.UpdateBackground() has a type guard (line 84-89) that only clears BackgroundColor for LayoutView or ContentView when paint is null — for all other UIView subclasses (including UITextField/UIDatePicker used by DatePicker/TimePicker), it early-returns without clearing. DatePicker and TimePicker didn't have their own MapBackground registered for iOS/MacCatalyst (only Android/Windows had it), so they fell through to this broken path. ### Description of Change **Platform handler updates:** * Added internal `MapBackground` methods to both `DatePickerHandler` and `TimePickerHandler` for iOS and MacCatalyst, which remove the background layer and reset the background color when the `Background` property is set to `null`. * Updated property mappers in `DatePickerHandler.cs` and `TimePickerHandler.cs` to include the new `MapBackground` mapping for iOS and MacCatalyst. **Test coverage:** * Added a new test case page (`Issue36933`) that allows toggling the background of `DatePicker` and `TimePicker` between a color and `null` at runtime. * Added a UI test verifying that the background is cleared when set to `null` and can be set to a new color. **Code maintenance:** * Added missing `using Microsoft.Maui.Graphics;` directives to relevant files for background color handling. ### 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 #36933 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [x] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2"> | <video src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
… when set to null at runtime (#36934) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details: - DatePicker and TimePicker Background set to null at runtime does not clear the background on iOS and MacCatalyst. The previously set background color/brush remains visible. ### Root Cause of the issue: - On iOS, ViewExtensions.UpdateBackground() has a type guard (line 84-89) that only clears BackgroundColor for LayoutView or ContentView when paint is null — for all other UIView subclasses (including UITextField/UIDatePicker used by DatePicker/TimePicker), it early-returns without clearing. DatePicker and TimePicker didn't have their own MapBackground registered for iOS/MacCatalyst (only Android/Windows had it), so they fell through to this broken path. ### Description of Change **Platform handler updates:** * Added internal `MapBackground` methods to both `DatePickerHandler` and `TimePickerHandler` for iOS and MacCatalyst, which remove the background layer and reset the background color when the `Background` property is set to `null`. * Updated property mappers in `DatePickerHandler.cs` and `TimePickerHandler.cs` to include the new `MapBackground` mapping for iOS and MacCatalyst. **Test coverage:** * Added a new test case page (`Issue36933`) that allows toggling the background of `DatePicker` and `TimePicker` between a color and `null` at runtime. * Added a UI test verifying that the background is cleared when set to `null` and can be set to a new color. **Code maintenance:** * Added missing `using Microsoft.Maui.Graphics;` directives to relevant files for background color handling. ### 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 #36933 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [x] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2"> | <video src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
… when set to null at runtime (#36934) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details: - DatePicker and TimePicker Background set to null at runtime does not clear the background on iOS and MacCatalyst. The previously set background color/brush remains visible. ### Root Cause of the issue: - On iOS, ViewExtensions.UpdateBackground() has a type guard (line 84-89) that only clears BackgroundColor for LayoutView or ContentView when paint is null — for all other UIView subclasses (including UITextField/UIDatePicker used by DatePicker/TimePicker), it early-returns without clearing. DatePicker and TimePicker didn't have their own MapBackground registered for iOS/MacCatalyst (only Android/Windows had it), so they fell through to this broken path. ### Description of Change **Platform handler updates:** * Added internal `MapBackground` methods to both `DatePickerHandler` and `TimePickerHandler` for iOS and MacCatalyst, which remove the background layer and reset the background color when the `Background` property is set to `null`. * Updated property mappers in `DatePickerHandler.cs` and `TimePickerHandler.cs` to include the new `MapBackground` mapping for iOS and MacCatalyst. **Test coverage:** * Added a new test case page (`Issue36933`) that allows toggling the background of `DatePicker` and `TimePicker` between a color and `null` at runtime. * Added a UI test verifying that the background is cleared when set to `null` and can be set to a new color. **Code maintenance:** * Added missing `using Microsoft.Maui.Graphics;` directives to relevant files for background color handling. ### 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 #36933 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [x] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2"> | <video src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
… when set to null at runtime (#36934) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details: - DatePicker and TimePicker Background set to null at runtime does not clear the background on iOS and MacCatalyst. The previously set background color/brush remains visible. ### Root Cause of the issue: - On iOS, ViewExtensions.UpdateBackground() has a type guard (line 84-89) that only clears BackgroundColor for LayoutView or ContentView when paint is null — for all other UIView subclasses (including UITextField/UIDatePicker used by DatePicker/TimePicker), it early-returns without clearing. DatePicker and TimePicker didn't have their own MapBackground registered for iOS/MacCatalyst (only Android/Windows had it), so they fell through to this broken path. ### Description of Change **Platform handler updates:** * Added internal `MapBackground` methods to both `DatePickerHandler` and `TimePickerHandler` for iOS and MacCatalyst, which remove the background layer and reset the background color when the `Background` property is set to `null`. * Updated property mappers in `DatePickerHandler.cs` and `TimePickerHandler.cs` to include the new `MapBackground` mapping for iOS and MacCatalyst. **Test coverage:** * Added a new test case page (`Issue36933`) that allows toggling the background of `DatePicker` and `TimePicker` between a color and `null` at runtime. * Added a UI test verifying that the background is cleared when set to `null` and can be set to a new color. **Code maintenance:** * Added missing `using Microsoft.Maui.Graphics;` directives to relevant files for background color handling. ### 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 #36933 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [x] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2"> | <video src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
… when set to null at runtime (#36934) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details: - DatePicker and TimePicker Background set to null at runtime does not clear the background on iOS and MacCatalyst. The previously set background color/brush remains visible. ### Root Cause of the issue: - On iOS, ViewExtensions.UpdateBackground() has a type guard (line 84-89) that only clears BackgroundColor for LayoutView or ContentView when paint is null — for all other UIView subclasses (including UITextField/UIDatePicker used by DatePicker/TimePicker), it early-returns without clearing. DatePicker and TimePicker didn't have their own MapBackground registered for iOS/MacCatalyst (only Android/Windows had it), so they fell through to this broken path. ### Description of Change **Platform handler updates:** * Added internal `MapBackground` methods to both `DatePickerHandler` and `TimePickerHandler` for iOS and MacCatalyst, which remove the background layer and reset the background color when the `Background` property is set to `null`. * Updated property mappers in `DatePickerHandler.cs` and `TimePickerHandler.cs` to include the new `MapBackground` mapping for iOS and MacCatalyst. **Test coverage:** * Added a new test case page (`Issue36933`) that allows toggling the background of `DatePicker` and `TimePicker` between a color and `null` at runtime. * Added a UI test verifying that the background is cleared when set to `null` and can be set to a new color. **Code maintenance:** * Added missing `using Microsoft.Maui.Graphics;` directives to relevant files for background color handling. ### 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 #36933 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [x] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2"> | <video src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
… when set to null at runtime (#36934) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details: - DatePicker and TimePicker Background set to null at runtime does not clear the background on iOS and MacCatalyst. The previously set background color/brush remains visible. ### Root Cause of the issue: - On iOS, ViewExtensions.UpdateBackground() has a type guard (line 84-89) that only clears BackgroundColor for LayoutView or ContentView when paint is null — for all other UIView subclasses (including UITextField/UIDatePicker used by DatePicker/TimePicker), it early-returns without clearing. DatePicker and TimePicker didn't have their own MapBackground registered for iOS/MacCatalyst (only Android/Windows had it), so they fell through to this broken path. ### Description of Change **Platform handler updates:** * Added internal `MapBackground` methods to both `DatePickerHandler` and `TimePickerHandler` for iOS and MacCatalyst, which remove the background layer and reset the background color when the `Background` property is set to `null`. * Updated property mappers in `DatePickerHandler.cs` and `TimePickerHandler.cs` to include the new `MapBackground` mapping for iOS and MacCatalyst. **Test coverage:** * Added a new test case page (`Issue36933`) that allows toggling the background of `DatePicker` and `TimePicker` between a color and `null` at runtime. * Added a UI test verifying that the background is cleared when set to `null` and can be set to a new color. **Code maintenance:** * Added missing `using Microsoft.Maui.Graphics;` directives to relevant files for background color handling. ### 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 #36933 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [x] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2"> | <video src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
… when set to null at runtime (#36934) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details: - DatePicker and TimePicker Background set to null at runtime does not clear the background on iOS and MacCatalyst. The previously set background color/brush remains visible. ### Root Cause of the issue: - On iOS, ViewExtensions.UpdateBackground() has a type guard (line 84-89) that only clears BackgroundColor for LayoutView or ContentView when paint is null — for all other UIView subclasses (including UITextField/UIDatePicker used by DatePicker/TimePicker), it early-returns without clearing. DatePicker and TimePicker didn't have their own MapBackground registered for iOS/MacCatalyst (only Android/Windows had it), so they fell through to this broken path. ### Description of Change **Platform handler updates:** * Added internal `MapBackground` methods to both `DatePickerHandler` and `TimePickerHandler` for iOS and MacCatalyst, which remove the background layer and reset the background color when the `Background` property is set to `null`. * Updated property mappers in `DatePickerHandler.cs` and `TimePickerHandler.cs` to include the new `MapBackground` mapping for iOS and MacCatalyst. **Test coverage:** * Added a new test case page (`Issue36933`) that allows toggling the background of `DatePicker` and `TimePicker` between a color and `null` at runtime. * Added a UI test verifying that the background is cleared when set to `null` and can be set to a new color. **Code maintenance:** * Added missing `using Microsoft.Maui.Graphics;` directives to relevant files for background color handling. ### 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 #36933 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [x] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2"> | <video src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
… when set to null at runtime (#36934) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details: - DatePicker and TimePicker Background set to null at runtime does not clear the background on iOS and MacCatalyst. The previously set background color/brush remains visible. ### Root Cause of the issue: - On iOS, ViewExtensions.UpdateBackground() has a type guard (line 84-89) that only clears BackgroundColor for LayoutView or ContentView when paint is null — for all other UIView subclasses (including UITextField/UIDatePicker used by DatePicker/TimePicker), it early-returns without clearing. DatePicker and TimePicker didn't have their own MapBackground registered for iOS/MacCatalyst (only Android/Windows had it), so they fell through to this broken path. ### Description of Change **Platform handler updates:** * Added internal `MapBackground` methods to both `DatePickerHandler` and `TimePickerHandler` for iOS and MacCatalyst, which remove the background layer and reset the background color when the `Background` property is set to `null`. * Updated property mappers in `DatePickerHandler.cs` and `TimePickerHandler.cs` to include the new `MapBackground` mapping for iOS and MacCatalyst. **Test coverage:** * Added a new test case page (`Issue36933`) that allows toggling the background of `DatePicker` and `TimePicker` between a color and `null` at runtime. * Added a UI test verifying that the background is cleared when set to `null` and can be set to a new color. **Code maintenance:** * Added missing `using Microsoft.Maui.Graphics;` directives to relevant files for background color handling. ### 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 #36933 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [x] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2"> | <video src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
… when set to null at runtime (#36934) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details: - DatePicker and TimePicker Background set to null at runtime does not clear the background on iOS and MacCatalyst. The previously set background color/brush remains visible. ### Root Cause of the issue: - On iOS, ViewExtensions.UpdateBackground() has a type guard (line 84-89) that only clears BackgroundColor for LayoutView or ContentView when paint is null — for all other UIView subclasses (including UITextField/UIDatePicker used by DatePicker/TimePicker), it early-returns without clearing. DatePicker and TimePicker didn't have their own MapBackground registered for iOS/MacCatalyst (only Android/Windows had it), so they fell through to this broken path. ### Description of Change **Platform handler updates:** * Added internal `MapBackground` methods to both `DatePickerHandler` and `TimePickerHandler` for iOS and MacCatalyst, which remove the background layer and reset the background color when the `Background` property is set to `null`. * Updated property mappers in `DatePickerHandler.cs` and `TimePickerHandler.cs` to include the new `MapBackground` mapping for iOS and MacCatalyst. **Test coverage:** * Added a new test case page (`Issue36933`) that allows toggling the background of `DatePicker` and `TimePicker` between a color and `null` at runtime. * Added a UI test verifying that the background is cleared when set to `null` and can be set to a new color. **Code maintenance:** * Added missing `using Microsoft.Maui.Graphics;` directives to relevant files for background color handling. ### 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 #36933 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [x] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2"> | <video src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
… when set to null at runtime (#36934) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details: - DatePicker and TimePicker Background set to null at runtime does not clear the background on iOS and MacCatalyst. The previously set background color/brush remains visible. ### Root Cause of the issue: - On iOS, ViewExtensions.UpdateBackground() has a type guard (line 84-89) that only clears BackgroundColor for LayoutView or ContentView when paint is null — for all other UIView subclasses (including UITextField/UIDatePicker used by DatePicker/TimePicker), it early-returns without clearing. DatePicker and TimePicker didn't have their own MapBackground registered for iOS/MacCatalyst (only Android/Windows had it), so they fell through to this broken path. ### Description of Change **Platform handler updates:** * Added internal `MapBackground` methods to both `DatePickerHandler` and `TimePickerHandler` for iOS and MacCatalyst, which remove the background layer and reset the background color when the `Background` property is set to `null`. * Updated property mappers in `DatePickerHandler.cs` and `TimePickerHandler.cs` to include the new `MapBackground` mapping for iOS and MacCatalyst. **Test coverage:** * Added a new test case page (`Issue36933`) that allows toggling the background of `DatePicker` and `TimePicker` between a color and `null` at runtime. * Added a UI test verifying that the background is cleared when set to `null` and can be set to a new color. **Code maintenance:** * Added missing `using Microsoft.Maui.Graphics;` directives to relevant files for background color handling. ### 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 #36933 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [x] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2"> | <video src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
… when set to null at runtime (#36934) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details: - DatePicker and TimePicker Background set to null at runtime does not clear the background on iOS and MacCatalyst. The previously set background color/brush remains visible. ### Root Cause of the issue: - On iOS, ViewExtensions.UpdateBackground() has a type guard (line 84-89) that only clears BackgroundColor for LayoutView or ContentView when paint is null — for all other UIView subclasses (including UITextField/UIDatePicker used by DatePicker/TimePicker), it early-returns without clearing. DatePicker and TimePicker didn't have their own MapBackground registered for iOS/MacCatalyst (only Android/Windows had it), so they fell through to this broken path. ### Description of Change **Platform handler updates:** * Added internal `MapBackground` methods to both `DatePickerHandler` and `TimePickerHandler` for iOS and MacCatalyst, which remove the background layer and reset the background color when the `Background` property is set to `null`. * Updated property mappers in `DatePickerHandler.cs` and `TimePickerHandler.cs` to include the new `MapBackground` mapping for iOS and MacCatalyst. **Test coverage:** * Added a new test case page (`Issue36933`) that allows toggling the background of `DatePicker` and `TimePicker` between a color and `null` at runtime. * Added a UI test verifying that the background is cleared when set to `null` and can be set to a new color. **Code maintenance:** * Added missing `using Microsoft.Maui.Graphics;` directives to relevant files for background color handling. ### 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 #36933 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [x] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2"> | <video src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
… when set to null at runtime (#36934) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details: - DatePicker and TimePicker Background set to null at runtime does not clear the background on iOS and MacCatalyst. The previously set background color/brush remains visible. ### Root Cause of the issue: - On iOS, ViewExtensions.UpdateBackground() has a type guard (line 84-89) that only clears BackgroundColor for LayoutView or ContentView when paint is null — for all other UIView subclasses (including UITextField/UIDatePicker used by DatePicker/TimePicker), it early-returns without clearing. DatePicker and TimePicker didn't have their own MapBackground registered for iOS/MacCatalyst (only Android/Windows had it), so they fell through to this broken path. ### Description of Change **Platform handler updates:** * Added internal `MapBackground` methods to both `DatePickerHandler` and `TimePickerHandler` for iOS and MacCatalyst, which remove the background layer and reset the background color when the `Background` property is set to `null`. * Updated property mappers in `DatePickerHandler.cs` and `TimePickerHandler.cs` to include the new `MapBackground` mapping for iOS and MacCatalyst. **Test coverage:** * Added a new test case page (`Issue36933`) that allows toggling the background of `DatePicker` and `TimePicker` between a color and `null` at runtime. * Added a UI test verifying that the background is cleared when set to `null` and can be set to a new color. **Code maintenance:** * Added missing `using Microsoft.Maui.Graphics;` directives to relevant files for background color handling. ### 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 #36933 ### Tested the behavior in the following platforms - [ ] Windows - [ ] Android - [x] iOS - [x] Mac ### Output | Before | After | |----------|----------| | <video src="https://github.com/user-attachments/assets/ba6de61f-99b8-49e5-8a72-2a38f26949d2"> | <video src="https://github.com/user-attachments/assets/bb75db1f-3370-4c10-9086-6798dbe0efb4"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
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:
Root Cause of the issue:
Description of Change
Platform handler updates:
MapBackgroundmethods to bothDatePickerHandlerandTimePickerHandlerfor iOS and MacCatalyst, which remove the background layer and reset the background color when theBackgroundproperty is set tonull.DatePickerHandler.csandTimePickerHandler.csto include the newMapBackgroundmapping for iOS and MacCatalyst.Test coverage:
Issue36933) that allows toggling the background ofDatePickerandTimePickerbetween a color andnullat runtime.nulland can be set to a new color.Code maintenance:
using Microsoft.Maui.Graphics;directives to relevant files for background color handling.Issues Fixed
Fixes #36933
Tested the behavior in the following platforms
Output
withoutfix.mov
withfix.mov