Skip to content

Commit 1bf1df7

Browse files
committed
docs(autocomplete): fix a11y of autocomplete example
1 parent d81445b commit 1bf1df7

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ export class AutocompleteDemo {
8888
}
8989

9090
filterStates(val: string) {
91-
return val ? this.states.filter((s) => s.name.match(new RegExp(val, 'gi'))) : this.states;
91+
return val ? this.states.filter(s => new RegExp(`^${val}`, 'gi').test(s.name))
92+
: this.states;
9293
}
9394

9495
}

src/examples/autocomplete-overview/autocomplete-overview-example.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ export class AutocompleteOverviewExample {
7171
}
7272

7373
filterStates(val: string) {
74-
return val ? this.states.filter((s) => new RegExp(val, 'gi').test(s)) : this.states;
74+
return val ? this.states.filter(s => new RegExp(`^${val}`, 'gi').test(s))
75+
: this.states;
7576
}
7677

7778
}

src/lib/autocomplete/autocomplete.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class MyComp {
7575
}
7676

7777
filter(val: string): string[] {
78-
return this.options.filter(option => new RegExp(val, 'gi').test(option));
78+
return this.options.filter(option => new RegExp(`^${val}`, 'gi').test(option));
7979
}
8080
}
8181
```
@@ -134,7 +134,7 @@ class MyComp {
134134
}
135135

136136
filter(name: string): User[] {
137-
return this.options.filter(option => new RegExp(name, 'gi').test(option));
137+
return this.options.filter(option => new RegExp(`^${name}`, 'gi').test(option));
138138
}
139139

140140
displayFn(user: User): string {

0 commit comments

Comments
 (0)