Skip to content

Fix Issue 12147: new focus target is not always announced#12252

Merged
michaelDCurran merged 6 commits into
nvaccess:masterfrom
mfairchild365:issue-12147
Apr 20, 2021
Merged

Fix Issue 12147: new focus target is not always announced#12252
michaelDCurran merged 6 commits into
nvaccess:masterfrom
mfairchild365:issue-12147

Conversation

@mfairchild365

Copy link
Copy Markdown
Contributor

Link to issue number:

fixes #12147

Summary of the issue:

The new focus target is not always announced when:

  1. The triggering button is activated while in browse mode
  2. The triggering button is removed
  3. The focus target is adjacent to where the triggering button was

This is because of the overlapping logic for browse mode focus changes that is used to prevent duplicate announcements. That overlapping logic did not account for this scenario.

See the linked codepens in #12147 for more examples.

I can not specially point to an instance of this in the wild, as all of my use-cases are behind a firewall. However, I know that this behavior is not unusual in SPA-style web apps.

Description of how this pull request fixes the issue:

This PR fixes the issue by altering the overlapping detecting logic so that:

  1. We look at the state of the previous focus object
  2. If the state of the previous focus object is DEFUNCT (no longer available) and an overlap was detected, then continue as if there was not an overlap.

Testing strategy:

  • I added a system test for this (I noticed that it times out from time to time, but that is likely an unrelated bug)
  • I manually tested against the linked codepens in the latest versions of Chrome, Firefox, and Edge to verify that this resolves the issue.

Known issues with pull request:

Change log entry:

Section: New features, Changes, Bug fixes

Code Review Checklist:

This checklist is a reminder of things commonly forgotten in a new PR.
Authors, please do a self-review and confirm you have considered the following items.
Mark items you have considered by checking them.
You can do this when editing the Pull request description with an x: [ ] becomes [x].
You can also check the checkboxes after the PR is created.

  • Pull Request description is up to date.
  • Unit tests.
  • System (end to end) tests.
  • Manual tests.
  • User Documentation.
  • Change log entry.
  • Context sensitive help for GUI changes.

If the previous focus object was removed, we might hit a false positive for overlap detection when the focus target is adjacent to the focus trigger.

This tracks the previous focus target so that we can account for this scenario when detecting overlaps.
@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit f280600b28

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 1eea41e921

@mfairchild365

Copy link
Copy Markdown
Contributor Author

I'm feeling pretty confident about this solution, but this is my first PR and dive into NVDA, so please let me know if I can improve it in any way.

@michaelDCurran michaelDCurran left a comment

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.

Thanks @mfairchild365 this is great.

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit e8b7de8ba9

@michaelDCurran michaelDCurran merged commit da3028a into nvaccess:master Apr 20, 2021
@nvaccessAuto nvaccessAuto added this to the 2021.1 milestone Apr 20, 2021
michaelDCurran added a commit that referenced this pull request Jun 8, 2021
…ates when checking if an object is defunct (dead), treat the object as defunct anyway. This ensures that the new focus will still be reported. (#12528)

Fixes #12527

Summary of the issue:
In UI Automation browse mode implementations, sometimes the new focus is not announced if the old focus is removed from the DOM as the focus changes. This is true even in focus mode.
PR #12252 introduced a check for STATE_DEFUNCT on the old focus's states property. Although this works fine in Firefox / Chrome (they leave dead objects around with a defunct state), some UI Automation elements become completely unusable, and therefore an exception is raised when trying to fetch the states property.
As reported in issue #12527 The newly focused tweet in the Twitter app is no longer announced when pressing j / keys. And If using Edge/Chromium with UIA, some focus changes in Microsoft Word 365 Online are not announced.

Description of how this pull request fixes the issue:
In BrowseMode document's event_gainFocus method, Catch all exceptions when fetching states to check for defunct, and if an exception is raised, log the error and treat the object as being defunct.
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.

New focus target is not always announced

4 participants