-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(list-key-manager): add support for horizontal directions #9122
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
Conversation
src/cdk/a11y/list-key-manager.ts
Outdated
* Configures the directions in which the user can move the selection. | ||
* @param directions One or more directions that the user can move the selection in. | ||
*/ | ||
withDirections(...directions: ListKeyManagerDirection[]): this { |
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.
What do you think of making this two method: withVerticalOrientation()
and withHorizontalOrientation(dir)
?
What did you have in mind for cases when it could have both turned on?
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.
API-wise I'm fine with having separate methods, but it would make it slightly less convenient to deal with internally.
Regarding use cases, off the top of my head there are a couple:
- Based on the a11y guidelines, horizontal tabs navigate using left/right arrows, whereas vertical tabs (which we use for the stepper) use both left/right and up/down.
- Native
select
elements allow you to change the value when closed both by pressing the up/down arrows, as well as left/right.
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.
Hmmmm.........
My main reason or not liking everything in one method is that it lets users provide an invalid combination (even though it's caught). Another option would be to separate the orientation from the direction into separate methods, so you'd have something like
withOrientation(...orientations: Horizontal | Vertical) { }
withDirectionality(dir) { } // defaults to LTR
Updates the `ListKeyManager` to add support for using ltr and rtl directions. This will allow us to switch over even more components to the key manager (e.g. chips, tabs, stepper) as well as support more use cases (e.g. moving selection with the left/right arrows on a closed select).
2eeed02
to
179feb0
Compare
Reworked based on the feedback @jelbourn. |
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
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. |
Updates the
ListKeyManager
to add support for using ltr and rtl directions. This will allow us to switch over even more components to the key manager (e.g. chips, tabs, stepper) as well as support more use cases (e.g. moving selection with the left/right arrows on a closed select).