-
Notifications
You must be signed in to change notification settings - Fork 4k
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(module:time-picker): make keyboard navigation possible #3145
fix(module:time-picker): make keyboard navigation possible #3145
Conversation
Deploy preview for ng-zorro-master ready! Built with commit a594623 |
Codecov Report
@@ Coverage Diff @@
## master #3145 +/- ##
==========================================
- Coverage 95.39% 95.37% -0.03%
==========================================
Files 712 706 -6
Lines 14633 14516 -117
Branches 1929 1915 -14
==========================================
- Hits 13959 13844 -115
Misses 244 244
+ Partials 430 428 -2
Continue to review full report at Codecov.
|
[(ngModel)]="value"> | ||
</nz-time-picker-panel> | ||
<span tabindex=0 (focus)="close()" class="nz-tab-catching-span"></span> |
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.
Why class "nz-tab-catching-span"?
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.
Also the syntax tabindex=0
should be tabindex="0"
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.
Why class "nz-tab-catching-span"?
So that it is easier to handle in the future (if there is need) plus it is a bit self-documenting.
Also the syntax tabindex=0 should be tabindex="0"
Ok. I will fix that.
Hi @jimmytheneutrino , we're very grateful for your work! It would be better to provide the actual usage scenario for this PR (as i think there is no need to handle the enter key on |
@wilsoncook |
c5f594c
to
89f1d87
Compare
@wilsoncook |
@wilsoncook Could you please tell me what else needs to be done? |
@jimmytheneutrino Thanks for your PR, this belongs to |
5c23e0b
to
bc9f809
Compare
@wenqi73 @wilsoncook However, isn't a partial improvement better than no improvement? Please see the videos: I think that just this little bit could be a huge improvement in usability for some users. |
[(ngModel)]="value"> | ||
</nz-time-picker-panel> | ||
<span tabindex="0" (focus)="close()" class="nz-tab-catching-span"></span> |
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.
<span tabindex="0" (focus)="close()" class="nz-tab-catching-span"></span> | |
In theory the focus point should be moved to time picker panel when pressing Tab
, it should not close the panel.
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.
You mean the same way as it is done in the react version: https://ant.design/components/time-picker/ ?
But I am sure this is a UX bug in that version. This behaviour would be completely unusable with a keyboard. You need to press tab about a hundred times to get anything done there. In reality, choosing time on the time-picker is not needed if the user is already using the keyboard.
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.
The right way is: Users use Tab
to toggle HOUR/MINITE/SECOND/INPUT selection, use UP_ARROW
or DOWN_ARROW
to select number.
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.
Really? In order to input the time this way in the worst case the user needs 12 + 30 + 30 keystrokes.
Why would anyone do it if they can just input time with numbers, press tab and go to the next input on the form? The way you propose the user would just have to press tab 3 times more to skip through those selections.
The way I see its usage is that:
a) there are some users who use mouse to enter time - and the time panel is great for that,
b) but there are some 'more experienced' users who want to do it faster -- and they could use keyboard for that -- 6 strokes+tab -- might take less than 2 seconds.
Imagine a receptionist somewhere who does it every day, hundreds of times.
Of course, one could implement a special form for the case b), but if the standard component could do it, why not try with a standard one?
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.
We need to support to cover everywhere of the panel only use keyboard, I mean use Tab
to toggle when the panel is open, if user want to do it faster they can use 6 strokes + Enter
+ Tab
to switch to next element, the Tab
should not just close panel.
@@ -6,7 +6,8 @@ | |||
[placeholder]="nzPlaceHolder || ('TimePicker.placeholder' | nzI18n)" | |||
[(ngModel)]="value" | |||
readonly="readonly" | |||
(click)="open()"> | |||
(click)="open()" | |||
(keyup.enter)="open()"> |
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.
You should add the tests about your changes.
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.
Added tests.
bc9f809
to
6bdcee4
Compare
Tabbing away from time-picker overlay was not possible: It wrapped around and usually ended up in browser's address bar. Also, once you selected time-picker wrapper span, there was no way to open the overlay via keyboard. This fixes this. Tabbing away from overlay now focuses on time-picker wrapper span. Pressing enter on the wrapper span opens the overlay.
6bdcee4
to
a594623
Compare
@wenqi73 plz check this again |
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.
The behavior of TAB
key does not match our design.
As there is no update for a long time, the PR will be closed. |
Tabbing away from time-picker overlay was not possible: It wrapped
around and usually ended up in browser's address bar. Also, once you
selected time-picker wrapper span, there was no way to open the overlay
via keyboard.
This fixes this. Tabbing away from overlay now focuses on time-picker
wrapper span. Pressing enter on the wrapper span opens the overlay.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Tabbing away from time-picker overlay was not possible: It wrapped
around and usually ended up in browser's address bar. Also, once you
selected time-picker wrapper span, there was no way to open the overlay
via keyboard.
Issue Number: N/A
What is the new behavior?
Tabbing away from overlay now focuses on time-picker
wrapper span. Pressing enter on the wrapper span opens the overlay.
Does this PR introduce a breaking change?
Other information
The behavior (both current and new) can be observed on the main demo page (npm run site:start).