CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Block Comments: Make comment thread focusable and improve keyboard navigation #71883
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
Conversation
Size Change: +280 B (+0.01%) Total Size: 1.95 MB
βΉοΈ View Unchanged
|
cbf766f
to
e8faa2f
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Flaky tests detected in d200041. π Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18099522446
|
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.
Thanks for working on this! Here are a few changes I think would improve it:
- Map
esc
key to move focus back to the thread on an open thread. For long comment threads, navigating through an open thread might take a long time, so it should be closable. - Resolve button on an open thread should close & focus the thread.
- Agree that reading the whole list item is too much. I think it needs to react more like a control. An
aria-label
like "[first 5 words of first visible comment]" would help. Usearia-expanded
to indicate whether a comment is opened or closed. Enter when focused on an opened thread should also close the thread; addingesc
as a close option is something that I think would be better for usability, as well.
I tried a different aria-label. When a thread is focused, a screen reader should announce the following text.
I think this is consistent with #71843. |
My reason for including the comment text was related to WCAG 2.5.3: Label in Name, which stipulates that the visible text on a control is in the accessible name for that control. This is enable to support speech activation, and allow users to activate a control using the text they can see, rather than needing to position a cursor using speech or use grid selection controls. It's not 100% clear whether 2.5.3 applies in this case; it's applicable to user interface components, and the WCAG definition of a user interface control is "a part of the content that is perceived by users as a single control for a distinct function". I'm not sure that a user would perceive this panel that way. The question here becomes "how would a speech activation user activate this panel." Practically speaking, I'm not sure voice activation would perceive this panel as something that's command clickable - I couldn't get it do it, using the aria-label in this PR, so I suspect that ultimately won't matter here. I was able to do it pretty easily using the mouse grid, however. That's not efficient, but works. I do think that it should be possible to activate the panel using voice control without using the mouse grid, however. The logical thing to me is that if a user uses the 'Actions' panel to Edit a comment, that should activate 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.
Code looks good!
I tested this on a Mac using VoiceOver and navigating around the comments by keyboard. Everything worked much better with this PR vs trunk, nice work! |
Ok, so I applied the comment excerpt to aria-label in 6b99421. I had to create our own utility function, but it should work properly in locales other than English. For example, if the comment is
Is there any other information that should be provided? |
@t-hamano It might be good to include the object name in the |
Updated in 550e582 |
Are there any other blockers here? It would be nice to land this refactoring so that we can improve |
We can improve |
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.
Yes, this looks good from a code perspective.
I just wanted to ensure that accessibility improvements are also beneficial from @joedolson's perspective.
β¦vigation (WordPress#71883) * Block Comments: Make commment thread focusable * Restore thread id attirbute * Remove event.stopPropagation * Close focused thread by enter key * Close focused thread by esc key * Focus current thread when the thread is resolved * Add thread comment as aria-label * Add aria-label * Fix e2e test * Improve aria-label * Use comment excerpt for aria-label * Add "Comment: " prefix to comment aria label Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: joedolson <joedolson@git.wordpress.org> Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
@t-hamano, should we create an issue for e2e test coverage of this feature? |
Here it is: #71962 |
variant="tertiary" | ||
className="editor-collab-sidebar-panel__more-reply-button" | ||
onClick={ () => setFocusThread( thread.id ) } | ||
onClick={ () => setSelectedThread( thread.id ) } |
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.
While working on #71969, I noticed that clicking on "more replies" causes a focus loss.
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.
Good catch, I just wrote a PR about focus management, so I'll fix it there π
What? How?
This PR makes the comment thread container focusable, improving the keyboard navigation experience.
Why?
The Block Comments has a lot of a11y issues as reported in #71249, and there have also been many reports of issues with focus loss.
In some cases, we may want to move focus to the comment thread itself. I believe making the comment thread itself focusable should help solve the focus loss issue, especially.
How?
This PR has the following enhancements:
tabIndex={0}
.role="listitem"
to the threads and wrap them in an element with therole="list"
. This allows a screen reader to announce which thread in the list has focus.aria-expanded
attribute to the thread.Enter
on a focused thread expands or collapses that thread.Esc
in an opened thread closes the thread, and the thread gets focusedTesting Instructions
Testing Instructions for Keyboard
Screenshots or screencast
fd57c4905582e9a91957b59a604f4ba7.1.mp4