nvda
a7c0bffc - Fix NVDA+K not recognizing links with nested elements (#19428)

Commit
12 days ago
Fix NVDA+K not recognizing links with nested elements (#19428) Fixes #17363 ### Summary of the issue: Previously, the `NVDA+K` command failed to identify links when the caret was positioned on text wrapped in nested elements (e.g., `<strong>`, `<em>`, or `<span>`) within an `<a>` tag. This occurred because the command only checked the immediate object at the caret or its direct parent, missing links further up the hierarchy. ### Description of user facing changes: `NVDA+K` now correctly identifies and reports the destination of links even when the text at the caret position is formatted (e.g., bold or italicized) or contained within other nested elements. ### Description of developer facing changes: In `source/textInfos/__init__.py`: - Updated `_getLinkDataAtCaretPosition` to traverse up the object hierarchy (max 10 levels) to find an enclosing link if the current object is not one. - Added a docstring to `_getLinkDataAtCaretPosition`. - Refactored the logic to explicitly handle graphics inside links (preserving existing fix #14779) before checking for general link ancestors. ### Description of development approach: The solution involves checking the ancestors of the object at the caret position. If the current object is not a link, the code iterates up the parent chain until a link is found or the traversal limit (10 levels) is reached. This ensures robust detection of enclosing links while preventing infinite loops in case of malformed object trees. ### Testing strategy: - Verified `NVDA+K` on an HTML test case with links containing nested `<strong>`, `<em>`, and `<span>` tags. - Verified that `NVDA+K` still works for simple links. - Verified regression testing for graphics inside links (as per #14779). ### Known issues with pull request: None.
Author
Parents
Loading