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

Improve accessibility for interactive session cards #4061

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

ahmed-mgd
Copy link
Contributor

Fixes #664

  • Announce status changes to screen reader
  • Restore focus to elements when cards refresh

@ahmed-mgd ahmed-mgd marked this pull request as ready for review January 13, 2025 19:30
</div>
<div id="sr-live-region" aria-live="polite" class="visually-hidden"></div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea to put updates here. So much so that this should likely go to the application.html.erb so it's on every page.

import { pollAndReplace } from './turbo_shim';

const sessionStatusMap = new Map();

function checkStatusChanges() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the way you have this is a bit complicated. Instead of pulling things from text, you should just embed them in data attributes, for not only ease, but it's also less error prone if CSS classes change.

If you embed all this information into data attributes, like so

--- a/apps/dashboard/app/views/batch_connect/sessions/_panel.html.erb
+++ b/apps/dashboard/app/views/batch_connect/sessions/_panel.html.erb
@@ -1,5 +1,8 @@
 <div id="<%= "id_#{session.id}" %>" class="card session-panel mb-4"
-  data-id="<%= session.id%>" data-hash="<%= session.to_hash %>" >
+  data-id="<%= session.id %>" data-hash="<%= session.to_hash %>"
+  data-status="<%= status(session).downcase %>"
+  data-title="<%= session.title %>"
+  data-bc-card='true' >
   <%= render_card_partial('card_header', session) %>
   <%= render_card_partial('card_body', session) %>
 </div>

You can query on the same stuff and just extract the status.

document.querySelectorAll('[data-bc-card]')[0].dataset.status

Querying by classes like '.status' or even .card.session-panel can be error prone if we ever change those classes (card is a boostrap class, so we have no control it).

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset

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

Successfully merging this pull request may close these issues.

Interactive sessions cards not very accessable
3 participants