-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(select): add ability to cycle through options with arrow keys when closed #3313
Conversation
7ef1e47
to
bb8ab2e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one small comment. Feel free to add merge_ready
when ready.
src/lib/select/select.ts
Outdated
|
||
// TODO(crisbeto): native selects also cycle through the options with left/right arrows, | ||
// however the key manager only supports up/down at the moment. | ||
this._keyManager.onKeydown(event); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment like
// Cycle though the select options even when the select is closed,
// matching the behavior of the native select element.
73efa57
to
675a08d
Compare
Sorry for the delay on this one. Apparently I missed the notification and it also needed some refactoring after the mutli select PR got in. |
src/lib/select/select.ts
Outdated
@@ -533,11 +552,14 @@ export class MdSelect implements AfterContentInit, OnDestroy, OnInit, ControlVal | |||
* @returns Option that has the corresponding value. | |||
*/ | |||
private _selectValue(value: any): MdOption { | |||
let correspondingOption = this.options.find(option => option.value === value); | |||
let optionsArray = this.options.toArray(); | |||
let correspondingOptionIndex = optionsArray.findIndex(option => option.value === value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't use findIndex
inside of Google (Closure's type definition for array doesn't have it).
@crisbeto ping me when this one ready again
…en closed * Adds the ability for users to select options by focusing on a closed `md-select` and pressing the up/down arrow keys. * Fixes a bug that prevents the selection from going to the first item in a `ListKeyManager`, if there were no previously-selected items. * Adds an extra null check to the `FocusKeyManager` to avoid issues where the focused item is cleared. Fixes angular#2990.
675a08d
to
d90b796
Compare
Removed the |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
md-select
and pressing the up/down arrow keys.ListKeyManager
, if there were no previously-selected items.FocusKeyManager
to avoid issues where the focused item is cleared.Fixes #2990.