File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
src/lib/forms/floating-label Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 114
114
115
115
function selectItem(item : string ) {
116
116
const currentValue = (value as string ) || ' ' ;
117
- const lastSpaceIndex = currentValue .lastIndexOf (' ' );
117
+ const lastSpaceIndex = currentValue .lastIndexOf (' ' );
118
+
119
+ if (lastSpaceIndex === - 1 ) {
120
+ value = item + ' ' ; // Replace the whole value if no space, add trailing space
121
+ } else {
122
+ value = currentValue .substring (0 , lastSpaceIndex + 1 ) + item + ' ' ; // Replace last word, add trailing space
123
+ }
118
124
119
- if (lastSpaceIndex === - 1 ) {
120
- value = item + ' ' ; // Replace the whole value if no space, add trailing space
121
- } else {
122
- value = currentValue .substring (0 , lastSpaceIndex + 1 ) + item + ' ' ; // Replace last word, add trailing space
123
- }
124
125
if (onSelect ) onSelect (item );
125
126
filteredSuggestions = [];
126
127
selectedIndex = - 1 ;
You can’t perform that action at this time.
0 commit comments