Repository navigation
Announce the current name of a UIA element that gains focus while its name changes - #21130
Open
LeonarddeR wants to merge 3 commits into
Open
LeonarddeR wants to merge 3 commits into
LeonarddeR wants to merge 3 commits into
Conversation
Objects created for UIA focus events no longer use the name cached with the event. The name is fetched with the other properties prefetched on focus. Fixes nvaccess#21116 Assisted-by: Claude:claude-opus-5-5
LeonarddeR
requested review from
SaschaCowley
and
a balanced review from Copilot
November 10, 2026 09:04
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The stale-name fix lacks automated regression coverage verifying both exclusion of Name from the initial focus-event cache and retrieval of the current name during focus prefetch.
1 open issue
What changed in this PR
This PR addresses #21116 by refreshing UI Automation element names during focus handling, avoiding stale announcements introduced by event-cache reuse in #20608.
Changes:
- Excludes
Namefrom cached properties used to construct focus-event objects. - Adds
Nameto the existing batched focus-property fetch. - Documents the user-facing fix for cases such as Unigram messages and renamed files.
| File | Description |
|---|---|
user_docs/en/changes.md |
Adds a changelog entry for corrected focus announcements. |
source/UIAHandler/__init__.py |
Excludes cached names when constructing focus-event objects. |
source/NVDAObjects/UIA/__init__.py |
Includes names in focus prefetch and annotates the property set. |
Review effort: Balanced
Assisted-by: Claude:claude-opus-5-5
Assisted-by: Claude:claude-opus-5-5
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Link to issue number:
Fixes #21116
Summary of the issue:
When a UI Automation element gains focus, NVDA reports its name from the values UI Automation cached when the application raised the focus event. Some applications raise the focus event just before they change the element's name. NVDA then announces the old name.
Description of user facing changes:
NVDA announces the current name of an item that gains focus while its name changes. Examples are a message in Unigram after jumping through a long chat, and a file in File Explorer after renaming it.
Description of developer facing changes:
None.
Description of development approach:
NVDA registers its UI Automation event handlers with a cache request. When an application raises an event, UI Automation fetches the requested properties at that moment. It delivers them together with the event. The name is one of these properties.
Since #20608, the object NVDA creates for an event uses these cached values. Before that, the object ignored them. It asked the application for the name when NVDA handled the event. Such a request waits for the application's user interface thread. By then, the application has usually finished changing the name. NVDA 2026.2 therefore announced the new name.
This pull request changes two things:
_focusEventCachedPropertyIDsinUIAHandler. It is passed asinitialUIACachedPropertyIDs._focusPrefetchUIAPropertyIDson the UIA NVDAObject.NVDA now reads the name when it handles the focus event, as it did in 2026.2. The normal path makes no extra request, because the name joins a request NVDA already made. Code that reads the name earlier asks the application directly, as in 2026.2. Examples are overlay class selection and app modules.
Testing strategy:
The bug reproduces in File Explorer only occasionally, so File Explorer is not a reliable test.
@FrayxRulez, could you please test a build of this pull request with Unigram 13.1.1 or earlier?
Known issues with pull request:
None
Code Review Checklist: