@@ -115,9 +115,7 @@ protected override void OnParametersSet()
115115 Icon ??= IconTheme . GetIconByKey ( ComponentIcons . AutoFillIcon ) ;
116116 LoadingIcon ??= IconTheme . GetIconByKey ( ComponentIcons . LoadingIcon ) ;
117117
118- OnGetDisplayText ??= v => v ? . ToString ( ) ;
119- _displayText = Value is null ? "" : OnGetDisplayText ( Value ) ;
120-
118+ _displayText = GetDisplayText ( Value ) ;
121119 Items ??= [ ] ;
122120 }
123121
@@ -127,14 +125,16 @@ protected override void OnParametersSet()
127125 private async Task OnClickItem ( TValue val )
128126 {
129127 CurrentValue = val ;
130- _displayText = OnGetDisplayText ( val ) ;
128+ _displayText = GetDisplayText ( val ) ;
131129
132130 if ( OnSelectedItemChanged != null )
133131 {
134132 await OnSelectedItemChanged ( val ) ;
135133 }
136134 }
137135
136+ private string ? GetDisplayText ( TValue item ) => OnGetDisplayText ? . Invoke ( item ) ?? item ? . ToString ( ) ;
137+
138138 private List < TValue > Rows => _filterItems ?? Items . ToList ( ) ;
139139
140140 /// <summary>
@@ -157,8 +157,8 @@ public async Task TriggerFilter(string val)
157157 {
158158 var comparision = IgnoreCase ? StringComparison . OrdinalIgnoreCase : StringComparison . Ordinal ;
159159 var items = IsLikeMatch
160- ? Items . Where ( i => OnGetDisplayText ( i ) ? . Contains ( val , comparision ) ?? false )
161- : Items . Where ( i => OnGetDisplayText ( i ) ? . StartsWith ( val , comparision ) ?? false ) ;
160+ ? Items . Where ( i => OnGetDisplayText ? . Invoke ( i ) ? . Contains ( val , comparision ) ?? false )
161+ : Items . Where ( i => OnGetDisplayText ? . Invoke ( i ) ? . StartsWith ( val , comparision ) ?? false ) ;
162162 _filterItems = items . ToList ( ) ;
163163 }
164164
0 commit comments