nvaccess / nvda

NVDA, the free and open source Screen Reader for Microsoft Windows
https://www.nvaccess.org/
Other
2.09k stars 630 forks source link

aria-live / role alert not announcing always with focus management #11299

Open elachapman opened 4 years ago

elachapman commented 4 years ago

Steps to reproduce:

In our application we have a confirmation modal that closes, throwing a success message in a snackbar that needs to be announced. There is focus management that in some instances moves focus to a button and in other it moves to an H2.

We tested with both an aria-live="polite" region and role="alert" implementation to have the snackbar dynamically announced.

Actual behavior:

Case 1: Aria-live="polite"

Case 2: role="alert"

Expected behavior:

That both the snackbar and the element that receives focus would be announced by NVDA.

System configuration

NVDA installed/portable/running from source:

installed

NVDA version:

2019.3.1

Windows version:

Version 10.0.18362 Build 18362

Name and version of other software in use when reproducing the issue:

Firefox Version 77.0.1

Other information about your system:

none applicable

Other questions

Does the issue still occur after restarting your computer?

Yes

Have you tried any other versions of NVDA? If so, please report their behaviors.

No

If addons are disabled, is your problem still occuring?

Yes

Did you try to run the COM registry fixing tool in NVDA menu / tools?

No

Adriani90 commented 4 years ago

cc: @MarcoZehe, @jcsteh

jcsteh commented 4 years ago

A test case is needed here to provide a useful diagnosis. Thanks.

Adriani90 commented 4 years ago

@elachapman do you have a test case for us? Or a code snippet which reproduces this issue? Otherwise investigation is not really possible in this case.

TazmanianDI commented 3 years ago

@Adriani90 This seems to be a big problem for us as well. We've got a chat bot that returns focus in an input field when users interact with certain portions of the widget and the act of programmatically moving focus seems to interrupt the announcement of any changes in the live regions. Is there any way to make it not do that?

I've tried role="alert" and aria-live="assertive" which doesn't seem to matter.

Here's a repro case. Just click the button.

<!DOCTYPE html>
<html lang="en">

<head>
  <script>
    function doChange() {
      document.querySelector("#announcer").innerText = 'This is an announcement';
      document.querySelector("#input").focus();
    }
  </script>
</head>

<body>

Some stuff
<div id="announcer" aria-live="polite"></div>
<input id="input" type="text"/>
<button type="button" onClick="doChange()">Do Change</button>

</body>
</html>

It seems to me that a programmatic change in focus should be treated like a programmatic change to a live region and that it should be polite about it and inform the user what's happening without cancelling other notices.

I've also found in our application that sometimes the reading of focus change stops the live-region announcement even if the announcement comes after the focus change. Unfortunately when I try to simplify this to a basic repro case though, it doesn't seem to want to repro. But I've got cases where I have to insert random delays before doing a live-region announcement. Something like 100ms is not enough but 250ms is which is a very precarious situation to be in.

feerrenrut commented 3 years ago

Currently, a screen reader can't differentiate a programmatic change of focus from a user initiated change of focus. A user initiated change of focus is considered of higher importance than anything else and starts speech with a clean slate. Given that we can consider an aria-live update as non-user initiated speech, I think it makes sense to requeue it on focus change, or any action other than explicitly cancelling speech.

Adriani90 commented 3 months ago

I would expect NVDA reports something like "allet: x y happened" before reporting the focused button. This is how it works in desktop applications as well. cc: @SaschaCowley see https://github.com/nvaccess/nvda/issues/11299#issuecomment-770021780 for a minimal test case.