vain0x / DotNetKit.Wpf.AutoCompleteComboBox

ComboBox with filtering (auto-complete) for WPF
MIT License
71 stars 26 forks source link

ItemsSource is incorrect when changing text search for filtering #11

Closed nadege-hotellier closed 4 years ago

nadege-hotellier commented 4 years ago

I've come across this autocomplete but faced an issue when emptying the text search or changing the text. Indeed, after the first filter, the ItemsSource keeps the old filter and does not reset the collection so every research after that is compromised.

Way to reproduce in the demo :

I'm not allowed to push a fix on the repo so here we are : In the component source code (AutoCompleteComboBox.xaml.cs), method UpdateSuggestionList, defaultItemsFilter should be set to null to be able to apply the new filter on the initial items collection

if (text == previousText) return; // Fix : remove previous filter if the text to search does not contains or is smaller than the previous text if (previousText?.Length > text?.Length || !text.Contains(previousText ?? string.Empty)) { defaultItemsFilter = null; } // End of fix previousText = text;

kvpt commented 4 years ago

Hello, It's caused by the change I've made in #10. The goal was if a CollectionView is used and a filter is set, combine it with the combobox filter. So I retrieve the CollectionView filter in OnItemsChanged, but if no CollectionView is defined by the user the defaultItemsFilter will use the first value of the filter defined by the combobox. This is the part that cause the issue and need to be fixed. I will make some more tests, with and without CollectionView filter to find the better approach and make another PR which fix that.