@@ -775,20 +775,26 @@ private async Task RemoveMultipleText( string text )
775775 if ( SelectedTexts is null )
776776 return ;
777777
778- SelectedTexts . Remove ( text ) ;
779- await SelectedTextsChanged . InvokeAsync ( SelectedTexts ) ;
778+ var removed = SelectedTexts . Remove ( text ) ;
780779
781- if ( SelectionMode == AutocompleteSelectionMode . Multiple )
782- DirtyFilter ( ) ;
780+ if ( removed )
781+ {
782+ await SelectedTextsChanged . InvokeAsync ( SelectedTexts ) ;
783+
784+ if ( SelectionMode == AutocompleteSelectionMode . Multiple )
785+ DirtyFilter ( ) ;
786+ }
783787 }
784788
785789 private async Task RemoveMultipleValue ( TValue value )
786790 {
787791 if ( SelectedValues is null )
788792 return ;
789793
790- SelectedValues . Remove ( value ) ;
791- await SelectedValuesChanged . InvokeAsync ( SelectedValues ) ;
794+ var removed = SelectedValues . Remove ( value ) ;
795+
796+ if ( removed )
797+ await SelectedValuesChanged . InvokeAsync ( SelectedValues ) ;
792798 }
793799
794800 /// <summary>
@@ -814,8 +820,10 @@ public async Task RemoveMultipleTextAndValue( string text )
814820 if ( Disabled )
815821 return ;
816822
823+ var selectedValue = GetValueByText ( text ) ;
824+
817825 await RemoveMultipleText ( text ) ;
818- await RemoveMultipleValue ( GetValueByText ( text ) ) ;
826+ await RemoveMultipleValue ( selectedValue ) ;
819827
820828 if ( ( validationRef . ParentValidations ? . Mode ?? ValidationMode . Auto ) == ValidationMode . Auto )
821829 await validationRef . ValidateAsync ( ) ;
@@ -830,7 +838,17 @@ public async Task RemoveMultipleTextAndValue( string text )
830838 /// <returns></returns>
831839 public async Task RemoveMultipleTextAndValue ( TValue value )
832840 {
833- await RemoveMultipleText ( GetItemText ( value ) ) ;
841+ var text = GetItemText ( value ) ;
842+
843+ if ( string . IsNullOrEmpty ( text ) && SelectedValues is not null && SelectedTexts is not null )
844+ {
845+ var selectedValueIndex = SelectedValues . IndexOf ( value ) ;
846+
847+ if ( selectedValueIndex > - 1 && selectedValueIndex < SelectedTexts . Count )
848+ text = SelectedTexts [ selectedValueIndex ] ;
849+ }
850+
851+ await RemoveMultipleText ( text ) ;
834852 await RemoveMultipleValue ( value ) ;
835853
836854 if ( ( validationRef . ParentValidations ? . Mode ?? ValidationMode . Auto ) == ValidationMode . Auto )
@@ -1190,9 +1208,21 @@ public IEnumerable<TItem> GetItemsByText( string text )
11901208 /// <param name="text"></param>
11911209 /// <returns></returns>
11921210 private TValue GetValueByText ( string text )
1193- => SelectedValues is not null
1194- ? SelectedValues . FirstOrDefault ( x => GetItemText ( x ) == text )
1195- : default ;
1211+ {
1212+ if ( SelectedValues is not null && SelectedTexts is not null )
1213+ {
1214+ var selectedValueIndex = SelectedTexts . IndexOf ( text ) ;
1215+
1216+ if ( selectedValueIndex > - 1 && selectedValueIndex < SelectedValues . Count )
1217+ return SelectedValues [ selectedValueIndex ] ;
1218+ }
1219+
1220+ var item = GetItemByText ( text ) ;
1221+
1222+ return item is null
1223+ ? default
1224+ : GetItemValue ( item ) ;
1225+ }
11961226
11971227 private Color GetMultipleBadgeColor ( ) => Disabled
11981228 ? MultipleDisabledBadgeColor
0 commit comments