Repository navigation
Conversation
|
Hey there @kubaflo! 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 |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Is it possible to add a test? |
|
@rmarinho I've added a UiTest :) |
There was a problem hiding this comment.
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- src/Controls/tests/TestCases.HostApp/Issues/Issue25729.xaml: Language not supported
Comments suppressed due to low confidence (1)
src/Controls/src/Core/Picker/Picker.cs:351
- The new behavior in the ResetItems method needs to be covered by tests.
if (oldValue is null || (newValue?.Count ?? -1) < oldValue.Count)
| Handler?.UpdateValue(nameof(IPicker.Items)); | ||
|
|
||
| ClampSelectedIndex(); | ||
| if (oldValue is null || (newValue?.Count ?? -1) < oldValue.Count) |
There was a problem hiding this comment.
I feel like I am missing something here. (my brain is mush after new years) What was the cause of the issue that resulted in items being cleared? This appears to just make sure that the clamping only happens if there was no previous value or if there are less/no items in the new list.
Was there some ordering issue where it would always reset to -1 or something?
There was a problem hiding this comment.
This method 'ClampSelectedIndex()'
void ClampSelectedIndex()
{
var oldIndex = SelectedIndex;
var newIndex = SelectedIndex.Clamp(-1, Items.Count - 1);
//FIXME use the specificity of the caller
SetValue(SelectedIndexProperty, newIndex, SetterSpecificity.FromHandler);
// If the index has not changed, still need to change the selected item
if (newIndex == oldIndex)
UpdateSelectedItem(newIndex);
}There was a problem hiding this comment.
I see, but why does the clamping only need to happen sometimes? Or is it a bad-ish name and it is just for the SetValue line firing when it shouldn't? What happens now when the UpdateSelectedItem no longer fires? Will the SelectedItem not be updated, or will it happen later?
I am not sure I see how the "only update if it was null before" matters if the clamped value will end up in the same place. Assuming it was at pos -1 with a null list, we add a list and the pos is still -1. We change the list and the pos should still be -1. Or if it was pos 10 and the new list is 15 items, the clamped value should stay 10 and we would still want the updated SelectedItem.
There was a problem hiding this comment.
It is more like this:
When the binding is applied one more time, the ItemsCount is initially equal to 0 before it gets to its previous count and because of it the newIndex is set to -1
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
mattleibow
left a comment
There was a problem hiding this comment.
Something strange is happening here. I made some changes to bind the selected index and it seems to clamp across VMs. For example, one picker has 3 items and the other has 4. Picking the last item in the 4, and then switching back to the 3 seems to update the VM to also be 3.
Not sure if it is related...
Media1.mp4
I see that's not good. I'm trying to find another fix. I have a suspicion that the fix will involve SelectedIndex, because it is always set to 0 on iOS on context change |
|
I just found out that this also happens with the selected ITEM. If you go from 4 items to 3 items, then going back to the 4 items results in the selection changing. Media2.mp4 |
41fe294 to
5e235da
Compare
|
@mattleibow I've discovered a simpler fix. Basically there's no need for Hi @BurningLights Is there a super important reason that I've missed, so that it cannot be removed? |
|
any idea when this fix will be available? Google has SDK 35 requirement and we are stuck with Migration from Xamarin forms to MAUI due to this and couple of more issues. |

Description of Change
Issues Fixed
Fixes #25729
Simulator.Screen.Recording.-.iPhone.16.Pro.Max.-.2024-12-23.at.03.31.53.mp4
Simulator.Screen.Recording.-.iPhone.16.Pro.Max.-.2024-12-23.at.03.20.47.mp4