forked from valor-software/ngx-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(typeahead) stop selecting first result when displaying matches (v…
…alor-software#3983) * docs(typeahead) Add min length example to docs * chore(typeahead) Fix typo * chore(typeahead) incorrect comment * feat(typeahead) stop selecting first result when displaying matches Switches from always setting the first result to be the active one, and instead initially displays the result list with no active item. After the pressing down/up keys the first/last item will be selected. Also cleans up the keyboard interaction when alternating between navigating between matches with arrow keys and typing additional characters, by keeping the previous match selected if it continues to be a match with the new results, instead of the previous behavior of resetting to the first item selected. Closes valor-software#3965 * fix(typeahead): clean up * fix(typeahead): fix unit tests
- Loading branch information
Showing
11 changed files
with
293 additions
and
31 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
demo/src/app/components/+typeahead/demos/first-item-active/first-item-active.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<pre class="card card-block card-header mb-3">Model: {{selected | json}}</pre> | ||
<input [(ngModel)]="selected" | ||
[typeahead]="states" | ||
[typeaheadIsFirstItemActive]="false" | ||
class="form-control"> |
61 changes: 61 additions & 0 deletions
61
demo/src/app/components/+typeahead/demos/first-item-active/first-item-active.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'demo-typeahead-first-item-active', | ||
templateUrl: './first-item-active.html' | ||
}) | ||
export class DemoTypeaheadFirstItemActiveComponent { | ||
selected: string; | ||
states: string[] = [ | ||
'Alabama', | ||
'Alaska', | ||
'Arizona', | ||
'Arkansas', | ||
'California', | ||
'Colorado', | ||
'Connecticut', | ||
'Delaware', | ||
'Florida', | ||
'Georgia', | ||
'Hawaii', | ||
'Idaho', | ||
'Illinois', | ||
'Indiana', | ||
'Iowa', | ||
'Kansas', | ||
'Kentucky', | ||
'Louisiana', | ||
'Maine', | ||
'Maryland', | ||
'Massachusetts', | ||
'Michigan', | ||
'Minnesota', | ||
'Mississippi', | ||
'Missouri', | ||
'Montana', | ||
'Nebraska', | ||
'Nevada', | ||
'New Hampshire', | ||
'New Jersey', | ||
'New Mexico', | ||
'New York', | ||
'North Dakota', | ||
'North Carolina', | ||
'Ohio', | ||
'Oklahoma', | ||
'Oregon', | ||
'Pennsylvania', | ||
'Rhode Island', | ||
'South Carolina', | ||
'South Dakota', | ||
'Tennessee', | ||
'Texas', | ||
'Utah', | ||
'Vermont', | ||
'Virginia', | ||
'Washington', | ||
'West Virginia', | ||
'Wisconsin', | ||
'Wyoming' | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
demo/src/app/components/+typeahead/demos/min-length/min-length.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<pre class="card card-block card-header mb-3">Model: {{selected | json}}</pre> | ||
<input [(ngModel)]="selected" | ||
[typeahead]="states" | ||
[typeaheadMinLength]="0" | ||
class="form-control"> |
61 changes: 61 additions & 0 deletions
61
demo/src/app/components/+typeahead/demos/min-length/min-length.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'demo-typeahead-min-length', | ||
templateUrl: './min-length.html' | ||
}) | ||
export class DemoTypeaheadMinLengthComponent { | ||
selected: string; | ||
states: string[] = [ | ||
'Alabama', | ||
'Alaska', | ||
'Arizona', | ||
'Arkansas', | ||
'California', | ||
'Colorado', | ||
'Connecticut', | ||
'Delaware', | ||
'Florida', | ||
'Georgia', | ||
'Hawaii', | ||
'Idaho', | ||
'Illinois', | ||
'Indiana', | ||
'Iowa', | ||
'Kansas', | ||
'Kentucky', | ||
'Louisiana', | ||
'Maine', | ||
'Maryland', | ||
'Massachusetts', | ||
'Michigan', | ||
'Minnesota', | ||
'Mississippi', | ||
'Missouri', | ||
'Montana', | ||
'Nebraska', | ||
'Nevada', | ||
'New Hampshire', | ||
'New Jersey', | ||
'New Mexico', | ||
'New York', | ||
'North Dakota', | ||
'North Carolina', | ||
'Ohio', | ||
'Oklahoma', | ||
'Oregon', | ||
'Pennsylvania', | ||
'Rhode Island', | ||
'South Carolina', | ||
'South Dakota', | ||
'Tennessee', | ||
'Texas', | ||
'Utah', | ||
'Vermont', | ||
'Virginia', | ||
'Washington', | ||
'West Virginia', | ||
'Wisconsin', | ||
'Wyoming' | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.