-
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(dropdown): add keyboard navigation support #2683
feat(dropdown): add keyboard navigation support #2683
Conversation
So this will not be generally available until v3.3.0? What is the best way to get this feature in the meantime? |
What is expected date to release V3.3.0. I think I might have missed somewhere. :) |
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.
Hi, thanks for the PR, it's doing in the good direction!
It needs a bit of work though.
Several use cases are not taken into account.
- in bootstrap you can have arbitrary HTML and disabled items in the popup.
- some of the dropdown items might be disabled
See https://getbootstrap.com/docs/4.1/components/dropdowns/#menu-content
For example, please take a look at the dropdown implementation for bootstrap JS to be inspired:
https://github.com/twbs/bootstrap/blob/19f70f9d4ccca132f196011958c1b72462c698e7/js/src/dropdown.js#L398
It aslo might be a good idea to implement Home
and End
, but sure it's optional
Also some comments on style and naming, please see: https://github.com/ng-bootstrap/ng-bootstrap/wiki/Contributions%3A-Code-conventions
P.S. I haven't looked into tests yet.
Cheers
@pouncilt while this isn't merged you can add this git repo as your dependency. Should probably not used in production until it is merged into upstream. |
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.
Your last changes look good, thanks!
I was looking through bootstrap demos and I think that last use case that is broken is:
https://stackblitz.com/edit/js-ahkcg3?file=index.html
It doesn't work the same way with implementation in this PR: when the form input is focused and press arrow up/down, home or end, the focus shouldn't move to any of dropdown-items.
I guess we should listen that event is triggered by either one of the trigger elements or the dropdown-item to fix this. Will you have time to take a look at it?
(Otherwise I guess it can be handled separately)
Yeah, seems like a good idea. |
Also @pkozlowski-opensource wanted to explore a different implementation, ex. like adding a |
yeah, I've actually thought about that too. I could implement it for this PR too if you want. |
I've stumbled over a use case, which won't work in the current implementation. Now the dropdownAnchor is the surrounding div, so the dropdown width is equal to the component itself and not to the size of the input field, but with the latest changes in this PR, the dropdown can't be opened from the input field because it's not the anchor. I could implement this behavior in my component, but I feel like this should somehow be handled by the dropdown component. I think we should add another directive which opens the dropdown on ArrowDown. Not sure about the naming of such a directive though. |
Hey, @maxjoehnk ! I've taken a look at the last implementation, and looks like it's going to overly complex direction. What I meant was this: #2785 (opened a PR for demonstration purposes, rough implmentation): a new directive @pkozlowski-opensource could you also take a glance, please? That's what you were talking about? I would personally:
|
+1 bumping this. Our app needs these fixes after a 508 assessment. |
@maxjoehnk thanks a lot for working on this! |
Codecov Report
@@ Coverage Diff @@
## master #2683 +/- ##
==========================================
+ Coverage 92.34% 92.39% +0.04%
==========================================
Files 91 91
Lines 2862 2907 +45
Branches 458 467 +9
==========================================
+ Hits 2643 2686 +43
- Misses 162 163 +1
- Partials 57 58 +1
Continue to review full report at Codecov.
|
Before submitting a pull request, please make sure you have at least performed the following:
This is a resubmit for #1417 by @wolfgangteves updated for the latest master branch