Accessibility: Focus management in topics

AI-generated summary

The discussion focuses on improving accessibility, particularly focus management in topics. riking highlights issues with J/K navigation, focusable posts, and missing focus styles for post controls, proposing fixes like tabindex=0 and applying .d-hover to :focus. They also note that the “show more” action blurs focus, which should instead focus the first revealed button. A PR addressing these issues was submitted, though it doesn’t fix the “show more” problem. riking then identifies the need for a shortcut to focus the composer textarea, which they address in a separate PR (/t/-/78109/5). codinghorror supports this modular approach, advocating for small, focused PRs. kevinrobinson praises the work, acknowledging riking’s expertise and offering assistance.

I think that fixing the J/K navigation focus management will fix the first linked topic, and is a prerequisite for solving the second topic.

@kevinrobinson

List of problems noticed before creating this:

  • Posts need to be focusable in order to properly direct the screen reader to the first post it should be reading. I think that setting tabindex=0 and custom :focus styling is the best way to do this.

  • Post controls have outline: 0 set, and no custom :focus styles. This removes all focus styling from the buttons. I suggest applying the .d-hover rules to the :focus state.

  • Activating the … “show more” post action blurs focus; it should focus the first revealed button.

3 Likes

Here’s a PR. Does not fix the … issue.

Wrote the comment entirely with my keyboard after I decided that would be a good idea, and found another issue: we need a shortcut to focus the composer textarea. It was extremely annoying to get my focus back in the composer, especially because it’s not where I expected it to be in the taborder.

https://github.com/discourse/discourse/pull/5505

5 Likes

Ok then make it so.. small PRs that do individual specific things are easier to process than giant swaths of kitchen sink work.

4 Likes

Made a separate PR for composer refocus and restore from collapsed:

https://github.com/discourse/discourse/pull/5506

7 Likes

@riking this looks awesome! :slight_smile: It looks like you have a better understanding than I do of how to implement these changes within Discourse, but the gist of these changes look great to me. Let me know if I can help at all!

1 Like