Fix Issue 12147: new focus target is not always announced (#12252)
fixes #12147
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.