Skip to content
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

Merged
merged 1 commit into from
Apr 22, 2017

Conversation

crisbeto
Copy link
Member

  • 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 #2990.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Feb 26, 2017
@crisbeto crisbeto force-pushed the 2990/select-arrow-selection branch from 7ef1e47 to bb8ab2e Compare March 4, 2017 10:15
Copy link
Member

@jelbourn jelbourn left a 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.


// 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);
Copy link
Member

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.

@crisbeto crisbeto force-pushed the 2990/select-arrow-selection branch 2 times, most recently from 73efa57 to 675a08d Compare April 5, 2017 04:31
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Apr 5, 2017
@crisbeto
Copy link
Member Author

crisbeto commented Apr 5, 2017

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.

@@ -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);
Copy link
Member

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

@jelbourn jelbourn added the presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged label Apr 11, 2017
…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.
@crisbeto crisbeto force-pushed the 2990/select-arrow-selection branch from 675a08d to d90b796 Compare April 12, 2017 18:32
@crisbeto
Copy link
Member Author

crisbeto commented Apr 12, 2017

Removed the findIndex @jelbourn.

@kara kara removed the presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged label Apr 21, 2017
@kara kara merged commit 66e65c4 into angular:master Apr 22, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: down/up arrow keys activate select
4 participants