Skip to content

Commit bdf0286

Browse files
crisbetojelbourn
authored andcommitted
chore: fix error when searching for special characters in the autocomplete demo (#5213)
Fixes regex special characters causing the autocomplete in the demo app to throw. Relates to #3373.
1 parent 0ea2533 commit bdf0286

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/demo-app/autocomplete/autocomplete-demo.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ export class AutocompleteDemo {
8888
}
8989

9090
filterStates(val: string) {
91-
return val ? this.states.filter(s => new RegExp(`^${val}`, 'gi').test(s.name))
92-
: this.states;
93-
}
91+
if (val) {
92+
const filterValue = val.toLowerCase();
93+
return this.states.filter(state => state.name.toLowerCase().startsWith(filterValue));
94+
}
9495

96+
return this.states;
97+
}
9598
}

0 commit comments

Comments
 (0)