Add full keyboard interaction in new review request page
Review Request #10852 — Created Jan. 24, 2020 and updated
The new review request page before this change had a couple issues
when navigating the page through just the keyboard itself.
On Chrome for example, the user was able to tab through most input
fields exclusing the commitsView list and side bar. For Firefox,
and Safari, you could only tab through the repository filter search
bar, the select diff file, and branchesSelect view.Revamped the keyboard usability experience within the new review
request page so that the user can fully tab through the page going
forwards and can shift+tab backwards excluding the repository selection
side bar to be done in a future project. The user will first tab
through to the repository search field in the side bar, the RBTools tip,
the select file diff button, the branchesSelect view dropdown, and
finally the commitsView list where the user can navigate through each
commit using the up/down/tab keys. Press enter to open the dialog to
create a new review request.Note that you are unable to interact with the dialog if triggered by the
keyboard and currently the user can still tab through the commitsView
in the background even if the modal is open. A link is attached for
reference and will be fixed in a future request.
Manual tests:
- Full keyboard usability end to end from the repo search bar,
to RBTools tip, upload diff button, branchesView dropdown, and
finally to the commitsView on Chrome, Firefox, and Safari
- Tabbing in the commitsView, focusing on the correct commit
- Using the up/down arrow keys in the commitsView, focusing on
the correct commit
- Pressing the up key on the first commit brings focus back to the
branchesView
- A random combination of up/down/tab keys in commitsView,
move focus to an element outside the commitsView, and return focus
back to the first commit and all commits are navigated in order
with whatever up/down/tab key combination
- Shift+Tab full user flow starting from CommitsView going backwardsUnit Tests:
- All tests pass before these new changes and all tests still pass
after the addition of new tests
- Tabbing from the repo search bar in the side bar to RBTools tip link
- Tabbing from the RBTools tip to the upload diff button
- Tabbing from the upload diff button to branchesView
- Pressing the up key on the first commit brings focus back to the
branchesView
- Pressing the up/down arrow key presses within the commitsView making
sure we are on the correct commit
- Pressing the down/tab keys to get to the end of the commitsView list
making sure that focus is still within the view
- Shift+Tab for each element and that it can tab back to the previous
element
Description | From | Last Updated |
---|---|---|
This is great stuff, Monica. I loved seeing the demo. Something that stood out is that, due to the layout, … |
chipx86 | |
class names are usually kebab case and i think don't typically include view in them. also did you mean collection … |
hxqlin | |
iirc there's a constant defined for the enter key code already - i think $.ui.keyCode.ENTER ? also i believe which … |
hxqlin | |
not sure which key this corresponds to, but same comment above about using an already defined constant and possibly favoring … |
hxqlin | |
can you do this.views[this._currentElement].focus(); ? same thing as below |
hxqlin | |
since this is the class name of the view, i think $('.branchesSelectionView') could be replaced with this.$el |
hxqlin | |
same issue about which and using an already defined constant here. also, if this supports the tab key (keycode 9) … |
hxqlin | |
i think this._currentElement could be better named as this._activeCommitIndex or something similar; the name is kinda confusing. when i saw … |
hxqlin | |
same comment about keyCode and using a constant for the numeric value |
hxqlin | |
does this fn need a check to make sure .rb-c-search-field__input is actually the active element before moving focus to the … |
hxqlin | |
i think Handling should be lowercase to be consistent with the style in other tests |
hxqlin | |
i think CommitsView should be camel cased? |
hxqlin | |
you could put this into a beforeEach |
hxqlin | |
could you use toHaveBeenCalledWith(...) here to check the arguments? |
hxqlin | |
toHaveBeenCalledWith(...) ? |
hxqlin | |
toHaveBeenCalledWith(...) could be used here too i think |
hxqlin | |
toHaveBeenCalledWith(...) ? |
hxqlin | |
i think Handling should be lowercase |
hxqlin | |
could view.render(); and view.delegateEvents(); be put into a beforeEach? |
hxqlin | |
toHaveBeenCalledWith(...) ? |
hxqlin | |
toHaveBeenCalledWith(...) ? |
hxqlin | |
toHaveBeenCalledWith(...) ? |
hxqlin | |
maybe toHaveBeenCalledWith(...) here? |
hxqlin | |
same comment about which and using the ui constant |
hxqlin | |
same comment about possibly replacing $('.branchesSelectionView') with this.$el |
hxqlin | |
Do we need to stop propagation/prevent default here? |
david | |
Add a blank line between this block and the next |
david | |
Please wrap to 80 columns. |
david | |
Add a blank line above this one. |
david | |
Please wrap to 80 columns. |
david | |
Does this work even though view is never attached to the DOM? |
david | |
This should be written in the imperative mood ("Handle a keydown event") |
david | |
Imperative mood. |
david | |
Imperative mood. |
david | |
We don't need the inner parens on this first part. |
david | |
Let's align all of this with the opening (. We also don't need the inner parens: } else if (event.which … |
david | |
Imperative mood. |
david | |
Imperative mood. |
david | |
Imperative mood. |
david |
- Description:
-
Initial comments on the codebase for keyboard usability
on the new review request page and trying to get a conclusion on how to implement a solution. Image that shows the area where keyboard presses don't work
~ ~ https://reviews.reviewboard.org/users/bui1/file-attachments/e2be66c5-bfce-4c51-9000-18125211e1ac/
- Commit:
-
4c304e99d43ab7849ee4da364a99aec0bbb1b364ba059837930f98dcfa0f598f988c7bb022594e21
Checks run (2 succeeded)
- Summary:
-
WIP Add comments on potential solutions to review req keypressesWIP Add keyboard interaction in new review request page
- Description:
-
~ Initial comments on the codebase for keyboard usability
~ on the new review request page and trying to get ~ Initial code to get keyboard presses in the commitsView area to work
~ with up/down/tab keys. Unit tests are still WIP. - a conclusion on how to implement a solution. Image that shows the area where keyboard presses don't work
https://reviews.reviewboard.org/users/bui1/file-attachments/e2be66c5-bfce-4c51-9000-18125211e1ac/ - Commit:
-
ba059837930f98dcfa0f598f988c7bb022594e214340ea57bcc143637dfd98cc8d3f6722644f9f56
- Diff:
-
Revision 3 (+122)
Checks run (2 succeeded)
- Description:
-
Initial code to get keyboard presses in the commitsView area to work
with up/down/tab keys. Unit tests are still WIP. ~ Image that shows the area where keyboard presses don't work
~ Image that shows the area where keyboard presses don't work. To be fixed in future request.
https://reviews.reviewboard.org/users/bui1/file-attachments/e2be66c5-bfce-4c51-9000-18125211e1ac/ - Commit:
-
4340ea57bcc143637dfd98cc8d3f6722644f9f56ed80a94f75b8acecf23e311bb74c18cf3f9e2a45
- Diff:
-
Revision 4 (+115)
Checks run (2 succeeded)
- Commit:
-
ed80a94f75b8acecf23e311bb74c18cf3f9e2a452f23e76993d8bb415e2d5a7b3b898958dc483ab1
- Diff:
-
Revision 5 (+117)
Checks run (2 succeeded)
- Description:
-
~ Initial code to get keyboard presses in the commitsView area to work
~ with up/down/tab keys. Unit tests are still WIP. ~ Revamp the keyboard usability within the new review request page so that
~ the user can fully tab through the page (excluding the repository selection side + bar). ~ Image that shows the area where keyboard presses don't work. To be fixed in future request.
~ Unit Tests are a WIP
- https://reviews.reviewboard.org/users/bui1/file-attachments/e2be66c5-bfce-4c51-9000-18125211e1ac/ - Testing Done:
-
+ Manual tests:
+ - Full keyboard usability from the repo search bar, to RBTools tip, + upload diff button, branchesView dropdown, and finally to the commitsView + on Chrome, Firefox, and Safari + - Tabbing in the commitsView, focusing on the correct commit + - Using the up/down arrow keys in the commitsView + - Pressing the up key on the first commit brings focus back to the + branchesView + + Unit Test:
+ - Tabbing from the repo search bar in the side bar to RBTools tip + - Tabbing from RBTools tip to upload diff button + - Tabbing from upload diff button to branchesView + - Tabbing and up/down arrow key presses within the commitsView making + sure the correct commit has been focused + + Image that shows the area where keyboard presses don't work. To be fixed in future request.
+ https://reviews.reviewboard.org/users/bui1/file-attachments/e2be66c5-bfce-4c51-9000-18125211e1ac/ - Commit:
-
2f23e76993d8bb415e2d5a7b3b898958dc483ab1b53d610bde6713bab5ccd8995b5b621f8194d172
- Diff:
-
Revision 6 (+261 -1)
Checks run (2 succeeded)
- Description:
-
Revamp the keyboard usability within the new review request page so that
the user can fully tab through the page (excluding the repository selection side bar). ~ Unit Tests are a WIP
~ Unit Tests are a WIP and almost completed
- Commit:
-
b53d610bde6713bab5ccd8995b5b621f8194d17275852ebd4d1c6b07a61ae1ec40e3ed27f8b2a1ae
- Diff:
-
Revision 7 (+263 -1)
Checks run (2 succeeded)
- Summary:
-
WIP Add keyboard interaction in new review request pageAdd full keyboard interaction in new review request page
- Description:
-
~ Revamp the keyboard usability within the new review request page so that
~ the user can fully tab through the page (excluding the repository selection side ~ bar). ~ The new review request page before this change had a couple issues
~ when navigating the page through just the keyboard itself. ~ On Chrome for example, the user was able to tab through most input + fields exclusing the commitsView list and side bar. For Firefox, + and Safari, you could only tab through the repository filter search + bar, the select diff file, and branchesSelect view. ~ Unit Tests are a WIP and almost completed
~ Revamped the keyboard usability experience within the new review
+ request page so that the user can fully tab through the page + excluding the repository selection side bar to be done in a future + project. The user will first tab through to the repository search field + in the side bar, the RBTools tip, the select file diff button, the + branchesSelect view dropdown, and finally the commitsView list where + the user can navigate through each commit using the up/down/tab keys. + Press enter to open the dialog to create a new review request. + + Note that you are unable to interact with the dialog if triggered by the
+ keyboard and currently the user can still tab through the commitsView + in the background even if the modal is open. A link is attached for + reference and will be fixed in a future request. - Testing Done:
-
Manual tests:
~ - Full keyboard usability from the repo search bar, to RBTools tip, ~ upload diff button, branchesView dropdown, and finally to the commitsView ~ on Chrome, Firefox, and Safari ~ - Full keyboard usability end to end from the repo search bar, ~ to RBTools tip, upload diff button, branchesView dropdown, and ~ finally to the commitsView on Chrome, Firefox, and Safari - Tabbing in the commitsView, focusing on the correct commit ~ - Using the up/down arrow keys in the commitsView ~ - Using the up/down arrow keys in the commitsView, focusing on + the correct commit - Pressing the up key on the first commit brings focus back to the ~ branchesView ~ branchesView + - A random combination of up/down/tab keys in commitsView, + move focus to an element outside the commitsView, and return focus + back to the first commit and all commits are navigated in order + with whatever up/down/tab key combination ~ Unit Test:
~ - Tabbing from the repo search bar in the side bar to RBTools tip ~ - Tabbing from RBTools tip to upload diff button ~ - Tabbing from upload diff button to branchesView ~ - Tabbing and up/down arrow key presses within the commitsView making ~ sure the correct commit has been focused ~ ~ Image that shows the area where keyboard presses don't work. To be fixed in future request.
~ https://reviews.reviewboard.org/users/bui1/file-attachments/e2be66c5-bfce-4c51-9000-18125211e1ac/ ~ Unit Tests:
~ - All tests pass before these new changes and all tests still pass ~ after the addition of new tests ~ - Tabbing from the repo search bar in the side bar to RBTools tip link ~ - Tabbing from the RBTools tip to the upload diff button ~ - Tabbing from the upload diff button to branchesView ~ - Pressing the up/down arrow key presses within the commitsView making ~ sure we are on the correct commit ~ - Pressing the down/tab keys to get to the end of the commitsView list + making sure that focus is still within the view - Commit:
-
75852ebd4d1c6b07a61ae1ec40e3ed27f8b2a1ae0b8b6f2d83066f7a20676e98cf54cae8722cba19
- Diff:
-
Revision 8 (+272 -1)
Checks run (2 succeeded)
- Commit:
-
0b8b6f2d83066f7a20676e98cf54cae8722cba19946404b5689f5d7869eb6dee8fa709cf3a6c0603
- Diff:
-
Revision 9 (+274 -1)
Checks run (2 succeeded)
- Testing Done:
-
Manual tests:
- Full keyboard usability end to end from the repo search bar, to RBTools tip, upload diff button, branchesView dropdown, and finally to the commitsView on Chrome, Firefox, and Safari - Tabbing in the commitsView, focusing on the correct commit - Using the up/down arrow keys in the commitsView, focusing on the correct commit - Pressing the up key on the first commit brings focus back to the branchesView - A random combination of up/down/tab keys in commitsView, move focus to an element outside the commitsView, and return focus back to the first commit and all commits are navigated in order with whatever up/down/tab key combination Unit Tests:
- All tests pass before these new changes and all tests still pass after the addition of new tests - Tabbing from the repo search bar in the side bar to RBTools tip link - Tabbing from the RBTools tip to the upload diff button - Tabbing from the upload diff button to branchesView + - Pressing the up key on the first commit brings focus back to the + branchesView - Pressing the up/down arrow key presses within the commitsView making sure we are on the correct commit - Pressing the down/tab keys to get to the end of the commitsView list making sure that focus is still within the view
-
-
class names are usually kebab case and i think don't typically include
view
in them. also did you meancollection
here and notselection
? i might be misunderstanding that part but basically i think the class name should bebranches-collection
-
i was thinking about doing this for my work but i didn't get around to looking up how yet - glad i spotted it here!
-
iirc there's a constant defined for the enter key code already - i think
$.ui.keyCode.ENTER
? also i believewhich
is preferred overkeyCode
in jQuery - https://stackoverflow.com/questions/4471582/keycode-vs-which -
not sure which key this corresponds to, but same comment above about using an already defined constant and possibly favoring
which
instead ofkeyCode
-
-
since this is the class name of the view, i think
$('.branchesSelectionView')
could be replaced withthis.$el
-
same issue about
which
and using an already defined constant here. also, if this supports the tab key (keycode 9) i think this should also support shift+tab to go in the opposite direction (same behaviour as up arrow key) -
i think
this._currentElement
could be better named asthis._activeCommitIndex
or something similar; the name is kinda confusing. when i saw the constant defined at the top of the file, i thought it was referring to a DOM/jQuery node and not just the index of one -
-
does this fn need a check to make sure
.rb-c-search-field__input
is actually the active element before moving focus to the rbtools tip? -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
this.views[this._currentElement].$el.focus();
ended up working for me so we can treat that view as a jquery object but thanks for the suggestion! -
Attempted that but then I couldn't key press back up to the branch dropdown itself. I think it needs an explicit element to focus back to so I left it as
$('.branches-collection').focus();
instead. -
Ah I didn't know that shift+tab was a thing haha thats a cool tidbit I learned today from you then :)
Now that's something I'll implement for sure not just for this view but for the others as well
-
This event will only occur if there is a keydown on the search field input itself specified by
'keydown .rb-c-search-field__input': '_onKeyDown',
. Essentially this event happens when the element is in focus and the correct event occurs. The focus check happens implicitly I believe unless I'm interpreting this wrong. Could argue that this case would also apply to the otherkeydown
handlers in the other files. -
-
view.render()
can be put in the beforeEach but notview.delegateEvents
because the spies need to be setup first before this function is called. Essentially we want the spy wrapper callback to be called when the proper DOM event happens otherwise the tests will say the spy was not called. -
- Description:
-
The new review request page before this change had a couple issues
when navigating the page through just the keyboard itself. On Chrome for example, the user was able to tab through most input fields exclusing the commitsView list and side bar. For Firefox, and Safari, you could only tab through the repository filter search bar, the select diff file, and branchesSelect view. Revamped the keyboard usability experience within the new review
~ request page so that the user can fully tab through the page ~ excluding the repository selection side bar to be done in a future ~ project. The user will first tab through to the repository search field ~ in the side bar, the RBTools tip, the select file diff button, the ~ branchesSelect view dropdown, and finally the commitsView list where ~ the user can navigate through each commit using the up/down/tab keys. ~ Press enter to open the dialog to create a new review request. ~ request page so that the user can fully tab through the page going ~ forwards and can shift+tab backwards excluding the repository selection ~ side bar to be done in a future project. The user will first tab ~ through to the repository search field in the side bar, the RBTools tip, ~ the select file diff button, the branchesSelect view dropdown, and ~ finally the commitsView list where the user can navigate through each ~ commit using the up/down/tab keys. Press enter to open the dialog to + create a new review request. Note that you are unable to interact with the dialog if triggered by the
keyboard and currently the user can still tab through the commitsView in the background even if the modal is open. A link is attached for reference and will be fixed in a future request. - Testing Done:
-
Manual tests:
- Full keyboard usability end to end from the repo search bar, to RBTools tip, upload diff button, branchesView dropdown, and finally to the commitsView on Chrome, Firefox, and Safari - Tabbing in the commitsView, focusing on the correct commit - Using the up/down arrow keys in the commitsView, focusing on the correct commit - Pressing the up key on the first commit brings focus back to the branchesView - A random combination of up/down/tab keys in commitsView, move focus to an element outside the commitsView, and return focus back to the first commit and all commits are navigated in order ~ with whatever up/down/tab key combination ~ with whatever up/down/tab key combination + - Shift+Tab full user flow starting from CommitsView going backwards Unit Tests:
- All tests pass before these new changes and all tests still pass after the addition of new tests - Tabbing from the repo search bar in the side bar to RBTools tip link - Tabbing from the RBTools tip to the upload diff button - Tabbing from the upload diff button to branchesView - Pressing the up key on the first commit brings focus back to the branchesView - Pressing the up/down arrow key presses within the commitsView making sure we are on the correct commit - Pressing the down/tab keys to get to the end of the commitsView list ~ making sure that focus is still within the view ~ making sure that focus is still within the view + - Shift+Tab for each element and that it can tab back to the previous + element - Commit:
-
946404b5689f5d7869eb6dee8fa709cf3a6c06039fc362a14eb21699b1ab82d0bd584ea02ed4dedb
- Diff:
-
Revision 10 (+365 -1)
Checks run (2 succeeded)
-
-
This is great stuff, Monica. I loved seeing the demo.
Something that stood out is that, due to the layout, the focus indicator the browser uses isn't super helpful. It just appears as a line of focus, and it's not super clear which thing it's supposed to be indicating.
I think what we should do for the keyboard-based navigation is remove the focus outline (
outline: 0
) and instead set a background color (we can match the top bar's color maybe), so that it's very clear what item is currently the selected item.
- Commit:
-
9fc362a14eb21699b1ab82d0bd584ea02ed4dedbf49e5b2ff09765f73d8ee0c5798d3e04d50a1007
- Diff:
-
Revision 11 (+370 -1)
- Added Files:
Checks run (2 succeeded)
- Commit:
-
f49e5b2ff09765f73d8ee0c5798d3e04d50a1007d5b8276155e59b835b1771152fc209a0ed41a431
- Diff:
-
Revision 12 (+377 -1)
Checks run (2 succeeded)
- Commit:
-
d5b8276155e59b835b1771152fc209a0ed41a431dd35797496e5843b423391608208872f1896afc4
- Diff:
-
Revision 13 (+377 -1)