nvaccess / nvda

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

Firefox moves the system focus to the top of the page after leaving a dialog application with a grid inside #14861

Open Adriani90 opened 1 year ago

Adriani90 commented 1 year ago

Steps to reproduce:

  1. Open NVDA
  2. In firefox, open this Test case: https://codepen.io/daKmoR/pen/ZEeEMYw
  3. In Browse mode, press b until you land on "console button"
  4. Press NVDA+space bar to activate focus mode
  5. Press shift+tab to access the application dialog with the date grid
  6. In Case NVDA switched to browse mode, press NVDA+space bar to activate focus mode in this dialog.
  7. Now that the system focus is in the dialog, press ctrl+shift+space bar to leave the application
  8. Press tab

Actual behavior:

System focus is at the top of the page, pressing tab reports "Codepen home"

Expected behavior:

System focus should be on the console button since this was the focus before entering the application dialog. Pressing tab should report Assets". This works as expected in Chrome or Edge.

NVDA logs, crash dumps and other attachments:

System configuration

NVDA installed/portable/running from source:

Installed

NVDA version:

Version: alpha-28126,03c31e5b (2023.2.0.28126)

Windows version:

Windows 11 22 H2

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

Firefox 112

Other information about your system:

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 NVDA add-ons are disabled, is your problem still occurring?

yes

Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?

yes

Adriani90 commented 1 year ago

cc: @jcsteh

jcsteh commented 1 year ago
  1. Now that the system focus is in the dialog, press ctrl+shift+space bar to leave the application ... System focus should be on the console button since this was the focus before entering the application dialog.

This is not what actually happens. When you press NVDA+control+space, NVDA focuses the document, not the last thing that had focus in said document. You can confirm this by pressing NVDA+tab.

Pressing tab should report Assets".

I agree this would be ideal in this situation, but it's a bit controversial in terms of implementation. As noted above, when you press NVDA+control+space, NVDA focuses the document. Normally, the document is the first thing in the tab order (as it is here). The next thing in the tab order after the document is the first focusable element on the page. So, by one definition, Firefox is correct: the document got focus, so pressing tab should behave just as if you tabbed to the document. This way, tab order is always consistent: if the document has focus, tabbing will always take you to the same place. On the other hand, when you focus the document, Chrome seems to keep the tab order from when the button was focused. This is helpful here because the button previously had focus, but it also means that tab order can be inconsistent depending on where focus last landed before the document was focused.

Inconsistent though it may be, I think Chrome's behaviour is useful here, but I'm not sure if that breaks other use cases. I'll need to look into whether we can reasonably address this in Firefox.

That said, it's also worth considering whether NVDA should be trying to focus something more precise than the document when using NVDA+control+space.

jcsteh commented 1 year ago

It seems that blurring the focus in Firefox does keep the tab order: data:text/html,<button onclick="this.blur();">a</button><button>b Pressing space on "a" focuses the document. Pressing tab then focuses "b". So, perhaps the accessibility engine can try to blur where it makes sense.

However, this isn't going to work for ARIA documents: data:text/html,<body role="application"><div role="document" tabindex="0"><button autofocus>top of document</button><button>middle of document</button><div role="dialog"><button>in dialog</button> If you tab into the dialog, press NVDA+control+space and then press tab, you hit "top of document" in both browsers. Based on the expected results reported here, you'd expect to land on "middle of document". There's no way a browser can fix this.

Adriani90 commented 7 months ago

That said, it's also worth considering whether NVDA should be trying to focus something more precise than the document when using NVDA+control+space.

Yeah i think that would be ideal if technically possible.