-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Conversation
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.
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)', |
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.
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.
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.
ugh, and we can't just polyfill it?
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.
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. */ |
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.
Missing closing paren
…fill and thumb position.
88d2c6d
to
3378c27
Compare
return; | ||
} | ||
|
||
event.preventDefault(); |
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.
Should we only preventDefault
when it's one of the keys we care about? E.g., pressing spacebar should probably still scroll the page.
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.
default:
return;
:p
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.
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.
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.
Done
LGTM |
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. |
↑/→ = +1 step
↓/← = -1 step
page up = +10 step
page down = -10 step
home = jump to min
end = jump to max
blocked on #1663