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

fix(slider): keyboard support #1759

Merged
merged 11 commits into from
Nov 11, 2016
Merged

fix(slider): keyboard support #1759

merged 11 commits into from
Nov 11, 2016

Conversation

mmalerba
Copy link
Contributor

@mmalerba mmalerba commented Nov 7, 2016

↑/→ = +1 step
↓/← = -1 step
page up = +10 step
page down = -10 step
home = jump to min
end = jump to max

blocked on #1663

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 7, 2016
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.

Needs unit tests

(and eventually e2e tests for keyboard functionality)

'(keydown.end)': '_onEndKeyPressed($event)',
'(keydown.home)': '_onHomeKeyPressed($event)',
'(keydown.pagedown)': '_increment($event, -10)',
'(keydown.pageup)': '_increment($event, 10)',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, we can't use these keydown shorts right now; it uses KeyboardEvent.key, which isn't supported in Safari or in WebDriver. So we've got to go back to the single-handler-plus-switch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh, and we can't just polyfill it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to avoid adding any polyfills that Angular itself doesn't already use

@@ -254,6 +263,30 @@ export class MdSlider implements ControlValueAccessor {
this.onTouched();
}

/** Increments the slider by the given number of steps (negative number decrements. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing closing paren

return;
}

event.preventDefault();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we only preventDefault when it's one of the keys we care about? E.g., pressing spacebar should probably still scroll the page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default:
  return;

:p

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I missed that. Could you add a comment at the return like

// Return if the key is one that we don't specifically handle so we
// don't call preventDefault on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Nov 11, 2016
@jelbourn
Copy link
Member

LGTM

@jelbourn jelbourn merged commit 13b7dd0 into angular:master Nov 11, 2016
@mmalerba mmalerba deleted the slider-a11y branch November 18, 2016 00:34
@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.

3 participants