KEMBAR78
[iOS, Mac] Fix for Picker title is not displayed again when SelectedIndex is set to -1 by HarishwaranVijayakumar · Pull Request #30486 · dotnet/maui · GitHub
Skip to content

Conversation

HarishwaranVijayakumar
Copy link
Contributor

@HarishwaranVijayakumar HarishwaranVijayakumar commented Jul 8, 2025

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 an item is selected in the Picker, setting SelectedIndex back to -1 does not restore the original title.

Root Cause of the issue

  • On iOS/macOS, a UITextField (which MauiPicker inherits from) only shows the AttributedPlaceholder when the Text property is null or empty

  • When SelectedIndex changes from a valid index (like 2) to -1, the Text property still retained the previous selected item's text

  • Since Text wasn't cleared, the placeholder (picker title) couldn't be displayed, even though UpdatePickerTitle() was being called

Description of Change

  • Clear the text property before setting the placeholder

Issues Fixed

Fixes #30463
Fixes #31011

Tested the behaviour in the follwing platforms

  • - Windows
  • - Android
  • - Mac
  • - iOS

Output

Before Fix After Fix
Beforefix.mov
Afterfix.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jul 8, 2025
@dotnet-policy-service
Copy link
Contributor

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.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jul 8, 2025
@HarishwaranVijayakumar HarishwaranVijayakumar marked this pull request as ready for review July 10, 2025 04:49
@Copilot Copilot AI review requested due to automatic review settings July 10, 2025 04:49
@HarishwaranVijayakumar HarishwaranVijayakumar requested a review from a team as a code owner July 10, 2025 04:49
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that when a Picker’s SelectedIndex is reset to –1 on iOS/macOS, the original title (placeholder) is displayed again.

  • Clear the native control’s Text before updating the placeholder in UpdatePicker
  • Add a new UI test in TestCases.Shared.Tests to verify the placeholder reappears
  • Provide a HostApp page for the UI test under TestCases.HostApp

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Core/src/Platform/iOS/PickerExtensions.cs Clear platformPicker.Text before calling UpdatePickerTitle to allow the placeholder to show
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30463.cs Add a UITest to toggle SelectedIndex and verify the title returns
src/Controls/tests/TestCases.HostApp/Issues/Issue30463.cs Introduce a ContentPage with a Picker and Button for UI testing

@JessieCowie23
Copy link

@jsuarezruiz I'm currently facing this issue, how likely are we to get this change included in the next few weeks? I'm not sure if you're expected any more changes from @HarishwaranVijayakumar

@mahesh139
Copy link

mahesh139 commented Jul 31, 2025

I am also stuck with this issue for migrating my Xamarin Forms app to MAUI. (Microsoft.Maui.Controls 9.0.90)
google now has deadline for SDK 35 requirement and issues like this keep hindering migration to MAUI.
waiting for the fix for migration to go ahead.

@HarishwaranVijayakumar will this fix take care of situation where SelectedItem is cleared from View Model while using MVVM?

@HarishwaranVijayakumar
Copy link
Contributor Author

@mahesh139, Yes this will also work while using MVVM

@Bejasc
Copy link

Bejasc commented Aug 1, 2025

I'm also waiting on a fix for this - @jsuarezruiz @StephaneDelcroix is there any update? Hoping we can see this one soon 🤞

@jfversluis jfversluis added this to the .NET 9 SR11 milestone Aug 5, 2025
@dotnet dotnet deleted a comment from azure-pipelines bot Aug 6, 2025
@rmarinho
Copy link
Member

rmarinho commented Aug 6, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@dotnet dotnet deleted a comment from azure-pipelines bot Aug 6, 2025
@dotnet dotnet deleted a comment from jsuarezruiz Aug 6, 2025
@rmarinho rmarinho requested a review from jsuarezruiz August 6, 2025 13:15
@rmarinho rmarinho changed the base branch from main to inflight/candidate August 6, 2025 15:15
@rmarinho rmarinho merged commit f1df1a9 into dotnet:inflight/candidate Aug 6, 2025
124 of 129 checks passed
PureWeen added a commit that referenced this pull request Aug 8, 2025
---
title: ".NET MAUI main-to-inflight-candidate Release Notes"
date: 2025-08-08
version: "main-to-inflight-candidate"
comparison: "main...inflight/candidate"
full_changelog:
"main...inflight/candidate"
description: "Release notes for .NET MAUI main-to-inflight-candidate,
covering 10 commits with enhancements and improvements."
---

# .NET MAUI main-to-inflight-candidate Release Notes

**Version:** main-to-inflight-candidate  
**Comparison:** main...inflight/candidate  
**Generated:** August 08, 2025  
**Last Updated:** August 08, 2025  
**Latest Commit Range:** 7f99494  
**Total Commits:** 10

## What's Changed

This release includes 10 commits with various improvements, bug fixes,
and enhancements to the .NET MAUI framework.


### .NET MAUI Product Fixes
- Update MauiRecyclerView.cs by @github-actions[bot] in
#31050
- Added the GraphicsView base images for Windows and mac platforms by
@nivetha-nagalingam in #31018
- Fixed CollectionView does not update layout correctly when ItemsSource
changes by @Dhivya-SF4094 in #30978 -
Fixes #30953
- Fix duplicate app icon resizing by @jeremy-visionaid in
#30920
- Fixed GraphicsView event handlers are triggered even when IsEnabled is
set to False by @Dhivya-SF4094 in
#30755 - Fixes
#30649
- [iOS, Mac] Fix for Picker title is not displayed again when
SelectedIndex is set to -1 by @HarishwaranVijayakumar in
#30486 - Fixes
#31011,
#30463

### Testing
- [Testing] Feature matrix UITest Cases for GraphicsView Control by
@nivetha-nagalingam in #30781
- [Testing] Feature matrix UITest Cases for HybridWebView Control by
@NafeelaNazhir in #30613

### Housekeeping
- [create-pull-request] automated change by @github-actions[bot] in
#30890
- [create-pull-request] automated change by @github-actions[bot] in
#30700

**Full Changelog**:
main...inflight/candidate
SuthiYuvaraj pushed a commit to SuthiYuvaraj/maui that referenced this pull request Aug 12, 2025
…ndex is set to -1 (dotnet#30486)

* Fix for Picker title not restoring after deselection on iOS

* Modified test

* Modified AutomationID

* Modified testcase

* [tests] Add windows and mac snapshots

---------

Co-authored-by: Rui Marinho <me@ruimarinho.net>
rmarinho added a commit that referenced this pull request Aug 13, 2025
…ndex is set to -1 (#30486)

* Fix for Picker title not restoring after deselection on iOS

* Modified test

* Modified AutomationID

* Modified testcase

* [tests] Add windows and mac snapshots

---------

Co-authored-by: Rui Marinho <me@ruimarinho.net>
@github-actions github-actions bot locked and limited conversation to collaborators Sep 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-picker Picker community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios platform/macos macOS / Mac Catalyst

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS Picker Text not clearing when using SelectedIndex = -1 [iOS, Mac] Picker title is not displayed again when SelectedIndex is set to -1

7 participants