Skip to content

button to announce remaining time on test - #3099

Open
Alex-Jordan wants to merge 1 commit into
openwebwork:WeBWorK-2.21from
Alex-Jordan:timer-button
Open

button to announce remaining time on test#3099
Alex-Jordan wants to merge 1 commit into
openwebwork:WeBWorK-2.21from
Alex-Jordan:timer-button

Conversation

@Alex-Jordan

@Alex-Jordan Alex-Jordan commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

See revised description two posts below.

First, this adds a button under the Gateway Test countdown clock that says "Announce time remaining". If that button is pushed, a visually hidden div is updated with the current amount of remaining time. This div is an aria-live region, and a screen reader user will hear the time.

The button itself should not be visually hidden. So there is a bit of an oddity here for sighted users who see this button and might think it does nothing. Are there any suggestions for improving that?

Now we have a button for a user to ask "How much time do I have left?" This means that the timer itself can be safely hidden to screen readers. So it is.

As usual, I haven't had success actually trying a screen reader to hear that this works. Related, I am not 100% sure that the time amount is formatted in a helpful way (e.g. "5 minutes", not "300 seconds"). But I am guessing that formatTime handles that well.

@Alex-Jordan

Copy link
Copy Markdown
Contributor Author

Claude suggests that clicking the button could trigger the toast that we already have. I'm gong to try that and update here if it seems good.

@Alex-Jordan

Copy link
Copy Markdown
Contributor Author

First, this adds a button under the Gateway Test countdown clock that says "Announce time remaining". If that button is pushed, there is a toast with the current amount of remaining time. This is an aria live region, and a screen reader user will hear the report.

Now we have a button for a user to ask "How much time do I have left?" This means that the timer itself can be safely hidden from screen readers. So it is.

This also potentially resolves an issue with the toasts that already exist (at 90 seconds, 45 seconds, and 0 seconds) where some screen readers were not announcing them. The issue might have been that the toast was inserted into the DOM fully constructed. Instead, inserting it empty, then updating it with content is the reliable way to get all (working) screen readers to read the update.

As usual, I haven't had success actually trying a screen reader to directly hear that this works.

@Alex-Jordan

Copy link
Copy Markdown
Contributor Author

And this makes one small styling improvement about rounded corners on the alert toasts that already existed.

@somiaj

somiaj commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

How do other platforms deal with this? I think a button is good, but there are already lots of buttons on tests. Is there a way to make the button only visible to screen readers? Would that be something worth considering or would it be nice to have that button there for everyone?

@drgrice1

Copy link
Copy Markdown
Member

The toast that announces the time is not good in dark mode.
bad-in-dark-mode

@Alex-Jordan

Copy link
Copy Markdown
Contributor Author

Is there a way to make the button only visible to screen readers?

No, this is not possible without violating a different accessibility issue. Users still need to get focus onto the button to use it. If you let focus land on an invisible thing, it is confusing to a sighted user.

@Alex-Jordan

Copy link
Copy Markdown
Contributor Author

The toast that announces the time is not good in dark mode.

I added alert alert-info classes to it, and it appears to respect dark mode now.

Comment on lines +59 to +62
requestAnimationFrame(() => {
toastContainer.querySelector('.toast-body span').textContent = text;
bsToast.show();
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't fix Gnome Orca not announcing the content. I wouldn't adjust code to try to get Gnome Orca to work. It often is not quite fully reliable for testing. That is why I try to test with NVDA. Unfortunately, that requires booting to windows.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, well that's too bad. It still sounds right to me that we should not insert the fully constructed div when it's an aria-live region. The explanation from Claude sounds reasonable, that some screen readers might only respond to an existing live region getting an update and not to a live region being inserted.

Are you recommending changes to the code here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not sure what is different with our code, but the live example at https://getbootstrap.com/docs/5.3/components/toasts/ is announced by Gnome Orca.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Claude has a few theories about why Gnome Orca is struggling here. I'll wait to discuss them with you sometime in the future.

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

Successfully merging this pull request may close these issues.

3 participants