-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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(rating): add keyboard support #1015
Conversation
@@ -28,6 +40,7 @@ export interface StarTemplateContext { | |||
@Component({ | |||
selector: 'ngb-rating', | |||
changeDetection: ChangeDetectionStrategy.OnPush, | |||
host: {'(keydown)': 'handleKeyDown($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.
Not sure if should be
keyup
- only increments by 1 once you release the keykeydown
- increments continuously by 1 while you hold the key
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 feel keyup makes more sense. I feel for a rating, I would want to press the button x amount of times for the rating I'm giving.
Holding down seems like it would be harder to select the exact number and would cause more mistakes than precise selections.
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.
Yeah, I'm still uncertain about this one, but the wai-aria slider demo and bootstrap js plugin use keydown apparently.
Plus from what I understand it's quite common to have this behaviour for navigation keys, so I'll leave it as is for now.
|
||
const createTestComponent = (html: string) => | ||
createGenericTestComponent(html, TestComponent) as ComponentFixture<TestComponent>; | ||
|
||
enum Key { | ||
PageUp = 33, |
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.
Maybe we should extract this whole enum somewhere (util?) as we start repeating it in few places now?
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.
Yes, I've thought of that too, will open a separate pr for this one
313b64f
to
33bfc81
Compare
Amended. Removed More links with examples: |
no idea why it's failing again with some |
No idea either, we need to update clang-format version. But for this we need to merge all the in-flight PRs :-) |
Adds rating support for the keyboard as follows:
Mostly based on https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_slider_role