diff --git a/source/globalCommands.py b/source/globalCommands.py index 57490c715cb..c79206a66f4 100755 --- a/source/globalCommands.py +++ b/source/globalCommands.py @@ -2785,6 +2785,7 @@ def _getNvdaObjWithAnnotationUnderCaret(self) -> Optional[NVDAObject]: relation' in that range, and we don't yet have a way for the user to select which one to report. For now, we minimise this risk by only reporting details at the current location. """ + _isDebugLogCatEnabled = bool(config.conf["debugLog"]["annotations"]) try: # Common cases use Caret Position: vbuf available or object supports text range # Eg editable text, or regular web content @@ -2792,28 +2793,26 @@ def _getNvdaObjWithAnnotationUnderCaret(self) -> Optional[NVDAObject]: caret: textInfos.TextInfo = api.getCaretPosition() except RuntimeError: log.debugWarning("Unable to get the caret position.", exc_info=True) - return None - caret.expand(textInfos.UNIT_CHARACTER) - objAtStart: NVDAObject = caret.NVDAObjectAtStart - _isDebugLogCatEnabled = bool(config.conf["debugLog"]["annotations"]) - if _isDebugLogCatEnabled: - log.debug(f"Trying with nvdaObject : {objAtStart}") - - if objAtStart.annotations: + else: + caret.expand(textInfos.UNIT_CHARACTER) + objAtStart: NVDAObject = caret.NVDAObjectAtStart if _isDebugLogCatEnabled: - log.debug("NVDAObjectAtStart of caret has details") - return objAtStart - elif api.getFocusObject(): + log.debug(f"Trying with nvdaObject : {objAtStart}") + if objAtStart.annotations: + if _isDebugLogCatEnabled: + log.debug("NVDAObjectAtStart of caret has details") + return objAtStart + + focus: NVDAObject = api.getFocusObject() + if focus: # If fetching from the caret position fails, try via the focus object # This case is to support where there is no virtual buffer or text interface and a caret position can # not be fetched. # There may still be an object with focus that has details. - # There isn't a known test case for this, however there isn't a known downside to attempt this. - focus = api.getFocusObject() if _isDebugLogCatEnabled: log.debug(f"Trying focus object: {focus}") - if objAtStart.annotations: + if focus.annotations: if _isDebugLogCatEnabled: log.debug("focus object has details, able to proceed") return focus diff --git a/user_docs/en/changes.md b/user_docs/en/changes.md index 4b17f666a29..271e9c2eba5 100644 --- a/user_docs/en/changes.md +++ b/user_docs/en/changes.md @@ -16,6 +16,7 @@ * When moving to an ARIA grid cell in focus mode in web browsers, NVDA no longer reports both the row and column headers even if only the row or only the column changed. (#17750, @jcsteh) * When an application stops responding, NVDA no longer freezes or floods its log with errors; it stays responsive and drops UIA and MSAA events from the unresponsive application until it recovers. (#16749, @heath-toby) * Reduced lag on UI Automation text change events, improving the responsiveness of controls such as combo boxes and of File Explorer, by using the cached element class name instead of a live cross-process fetch. (#16749, @heath-toby) +* In Mozilla Firefox, reporting annotation details now works correctly in focus mode on controls which are not editable text. (#20208, @jcsteh) ### Changes for Developers