Skip to content
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

Review/fix examples for accessibility #a11y #1431

Open
patrickhlauke opened this issue May 9, 2023 · 5 comments
Open

Review/fix examples for accessibility #a11y #1431

patrickhlauke opened this issue May 9, 2023 · 5 comments

Comments

@patrickhlauke
Copy link

With apologies for a rather high-level/vague issue (compared to more specific listings / PRs with proposed fixes), but: having skimmed a few of the examples provided on https://htmx.org/examples/ I'd note that the majority of the ones I've checked seem to lack at least a few basic keyboard accessibility requirements.

For demos involving buttons, there is currently no actual visible focus indication for when a button has/hasn't got focus.

Beyond that, a few specific issues:

  • the tab example is not keyboard-accessible (those <a> elements, since they lack an actual href, don't receive keyboard focus)
  • the reordering example can only be operated with the mouse

I was hoping to be able to jump in and evaluate the examples further for screen reader support (and in particular checking that focus is handled correctly/isn't lost and reset when fragments are reloaded/replaced), but these initial keyboard access problems are already an early-warning sign that there's likely further / more fundamental problems here that need to be addressed first, before even going down the SR testing/improvements route.

@patrickhlauke patrickhlauke changed the title Review/fix examples for accessibility Review/fix examples for accessibility #a11y May 9, 2023
@patrickhlauke
Copy link
Author

more bits/context here https://mastodon.social/@sil/110340406008743130 including

  • progress bar demo: after activating the button, focus is lost (as the button is replaced wholesale with the progress indicator, removing the currently focused element from under keyboard users' feet, which - in combination with some screen readers - results in focus being reset to the start of the page). this would be a great excuse to show how authors should actually handle focus programmatically in these cases...

@dz4k
Copy link
Collaborator

dz4k commented May 10, 2023

Possible mitigations:

  • Find/write good JS-based headless UI components that integrate well with htmx (emit events)
  • Experiment with implementing keyboard interactions with hx-on
  • Log console errors for common pitfalls:
    • if focus moves the the body after swapping
    • if an with htmx attributes lacks an href (we could also automatically add one)
    • ...

@MarcusMorba
Copy link

MarcusMorba commented Jul 13, 2023

I totally agree. Especially all examples in the "documentation" with "div-buttons" should use "button"-tag instead or add the required role and aria-attributes. Details and examples can be found on the ARIA Authoring Practices Guide (APG): https://www.w3.org/WAI/ARIA/apg/patterns/button/

Examples I viewed: https://htmx.org/docs/#introduction

yawaramin added a commit to yawaramin/htmx that referenced this issue Jan 27, 2024
And use ARIA to announce a summary of the bulk update. By using a
checkbox input to represent the activation status, we don't need to
re-render it when it's changed, because the checkbox itself manages that
state.

Re: bigskysoftware#1431
alexpetros pushed a commit that referenced this issue Feb 1, 2024
* Minimize re-rendering of 'bulk update users' table

And use ARIA to announce a summary of the bulk update. By using a
checkbox input to represent the activation status, we don't need to
re-render it when it's changed, because the checkbox itself manages that
state.

Re: #1431

* Improve screen reader pronunciation
rekado pushed a commit to rekado/htmx that referenced this issue Feb 9, 2024
* Minimize re-rendering of 'bulk update users' table

And use ARIA to announce a summary of the bulk update. By using a
checkbox input to represent the activation status, we don't need to
re-render it when it's changed, because the checkbox itself manages that
state.

Re: bigskysoftware#1431

* Improve screen reader pronunciation
FraserChapman pushed a commit to FraserChapman/htmx that referenced this issue Feb 16, 2024
* Minimize re-rendering of 'bulk update users' table

And use ARIA to announce a summary of the bulk update. By using a
checkbox input to represent the activation status, we don't need to
re-render it when it's changed, because the checkbox itself manages that
state.

Re: bigskysoftware#1431

* Improve screen reader pronunciation
@hibachrach
Copy link

hibachrach commented Oct 5, 2024

I'd also note that the modal dialog examples fail in at least a few ways:

  • Esc does not hide the modal dialog
  • Tab navigation is not trapped inside of the dialog
  • Initial focus is not set on something sensible (e.g. the exit button)

In terms of impact, note that "examples" are often interpreted by developers as "the right way to do X" or "copy this source code", so this could have consequences for websites built by folks new to HTMX.

@Telroshan
Copy link
Collaborator

PRs are always welcome to improve documentation btw, if you feel like it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants