Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editable combo box sets bound value to null when itemsource changes #9573

Closed
SoggyBottomBoy opened this issue Apr 23, 2024 · 6 comments
Closed
Labels
area-ComboBox bug Something isn't working team-Controls Issue for the Controls team

Comments

@SoggyBottomBoy
Copy link

Describe the bug

I have an editable combo box which allows the user to select predefined items or set another item by typing in its name. The combox box ItemsSource is bound to a list of strings which is changed when action is taken by the user which changes the list of predefined strings. When the ItemsSources changes it appears that the SelectedItem is set to null. I am unable to re-type the same value, and clicking the drop down repopulates the value.

I'm pretty confused about what is going on...

Steps to reproduce the bug

Create 2 editable combo boxes.
Have one 1 combo box ItemsSource rely on the value of the other.
Enter a value like "1" in the combo box.
Change the value of the other combo box to trigger a changes of the items source
The value in the editable combo box is replaced with null and "1" can not be entered.

Expected behavior

For an editable combo box change the items source should not re-trigger the value bound to selected item or text to change.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.5.2: 1.5.240404000

Windows version

Windows 11 (22H2): Build 22621

Additional context

No response

@SoggyBottomBoy SoggyBottomBoy added the bug Something isn't working label Apr 23, 2024
Copy link

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Apr 23, 2024
@codendone codendone added area-ComboBox team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Apr 26, 2024
@kmahone
Copy link
Member

kmahone commented May 9, 2024

I am having a hard time understanding the repro steps. Could you share some code and xaml that demonstrates the issue?

@SoggyBottomBoy
Copy link
Author

https://github.com/SoggyBottomBoy/EditableComboBoxBug
The second combox (bottom) is editable so enter in a value in the box, then change the section of the first box (top)

@kmahone
Copy link
Member

kmahone commented May 10, 2024

Thanks. I can reproduce the issue.

As you said, there are two issues here:

  1. When the ItemsSource changes, it resets the selection of the ComboBox. This usually makes sense, but in the case of an editable combobox, it probably should not happen.
  2. The inner TextBox of the ComboBox retains its old value. Normally when a user enters a value into the TextBox, the ComboBox will use that for the selection. But, it relies on the TextBox's TextChanging to trigger that. In this case, if the text does not actually change, it won't trigger that logic. So in order to select the old value, the user has to intentionally change it to something else and then change it back.

@SoggyBottomBoy
Copy link
Author

Yep but I think item 2 is somewhat solved by item 1. I would say an editable combox should be expected to retain the value if the ItemsSource is changed, if the developer does not want this behaviour then it should be an explicit opt in by handling ItemsSourceChanged or similar.

@karkarl
Copy link
Contributor

karkarl commented Dec 26, 2024

Resolving as dupe of #10232

@karkarl karkarl closed this as not planned Won't fix, can't repro, duplicate, stale Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ComboBox bug Something isn't working team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

4 participants