Change focus target on items when using keyboard navigation #2348
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose of this pull request
When focusing on an element in JavaScript, some screen readers will also announce its parent's label. When the focused element's label is the same as the parent's label, users may get the same text twice. macOS VoiceOver will announce two times; NVDA and JAWS will announce three times. Some screen reader users think this behavior should be adjust.
Current behavior
The current version focuses on the link element, and it is wrapped by a h2 tag, and the h2 tag is inside an article that has a label. This caused the screen reader behavior that I mentioned above.
H2 and the article's label can't be removed because screen reader users who preferred to navigate by heading or landmark/article will need this information.
The benefit of this approach is that when users use the keyboard shortcut to navigate, they can press the Enter key directly to open a link, without other actions. This is the default behavior of links. Users don't need to remember the Miniflux keyboard shortcut to open the selected item.
Change focus target to article
I changed the focus target to the article element, and then it will just announce the entry title once when using the screen reader.
After this change, users who use keyboard navigation will be affected. Either they have to press the tab once to focus on the link, then press the Enter key to open the link, or they need to remember the open selected item shortcut, which is the O key, then press the O key to open entry.
And the benefit of this approach is that screen reader users can get concise information. I have tested on macOS VoiceOver and Windows NVDA. It only announces the entry title once.
Do you follow the guidelines?