-
Notifications
You must be signed in to change notification settings - Fork 500
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 keyboard navigation in the single-column mail view #6862
Conversation
There is still a possible issue where the tab order and the selection via the arrow keys do not align. If you tab to the third row then press down for instance, the forth row will not be selected. I am not sure whether to fix this as the arrow keys and tab do slightly different things. The arrow keys focus and open a row while the tab just focuses a row.
src/gui/base/List.ts
Outdated
@@ -417,6 +415,10 @@ export class List<T, VH extends ViewHolder<T>> implements ClassComponent<ListAtt | |||
row.domElement.style.transform = `translateY(${row.top}px)` | |||
row.row.update(item, attrs.state.selectedItems.has(item), attrs.state.inMultiselect) | |||
} | |||
// Focus the selected row so it can receive keyboard events |
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 am concerned that we can't just grab focus here. What if user is in another part of the app but the list get updated?
I think we would need to check if focused element is inside of this list
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.
That is a good point. However if we only focus the selected element when the focus is on another item, I suspect this will break tab navigation as it will continually jump to the selected row on tab. I will investigate better places to focus it.
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 am stumped on finding a way to fix this without refactoring the List's code to allow the ListModel
to get the row's element from List
.
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.
That wouldn't be desirable.
I am not sure I understand the concern you expressed above. To me the algorithm is "focus the list row programmatically only when the focus is already inside the list". This doesn't change anything about manual tab navigation I think? Am I missing something?
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.
Ah, I thought programmatically focusing an element affected the tab index. My bad, doing a quick test shows otherwise.
The other issue is that requiring the focus to be inside the list row will change the behaviour in the other layouts. In master, pressing up and down anywhere regardless of focus in the double and three column views will change the selected row. This occurs when I tried only focusing when another row is focused via getting the tag name of the focused element.
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.
that's a good thing to think about but I think it still works.
Say you are in three-column layout. You press up/down.
- If your focus was in the list, it will move to another position, which is good
- If your focus was not in the list, it will just do the selection, without changing your focus, which is also good
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.
If you are happy with this behaviour outside the single-column layout then let's go for it. The issue's steps do not mention focusing the list for single-column so it would be best not to require it. I have pushed a compromise between the two 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.
thank you, I'll try to get back to it soon but I I want to test and get a feel for it first
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.
No worries, thanks for taking the time to review it. 🙂
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.
these are very good issues to fix but I only had a cursory look for now, I would like to look at it again and also test some more but I'm excited about improving it!
Thanks for taking a look into it. It is nice to hear that you wanted this fixed. I will address the issues you have mentioned so far. If you are planning to work on it, let me know so we do it together or at least not double up on work. |
As requested during PR review.
I am not sure how to test calendar, I cannot focus an agenda item with keyboard at all right now |
I believe the agenda view uses it's own component ( |
Oh, my bad, I tested calendar because I thought I was you mentioned it somewhere but I probably mixed it up |
I have just pushed a commit that fixes this and should be a better solution for the focus stealing issue. |
I've tested and I think your fix helps! I figured when/why our focus goes haywire. |
There is still a possible issue where the tab order and the selection via the arrow keys do not align. If you tab to the third row then press down for instance, the forth row will not be selected.
I am not sure whether to fix this as the arrow keys and tab do slightly different things. The arrow keys focus and open a row while the tab just focuses a row.
Closes #5361.