[orca] Web: Fix issue causing Orca to remain silent with autofocused inputs



commit 513880d40ca2cfc472027d083152a913ad76ec7b
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Fri Aug 26 12:44:19 2022 +0200

    Web: Fix issue causing Orca to remain silent with autofocused inputs
    
    When a text field is autofocused, we might get the caret-moved event
    prior to the focus event. In all cases, we update the locusOfFocus.
    However we were only announcing the new focus to the user in the case
    of entries and spin buttons; not editable combo boxes or password
    fields. This commit fixes that.
    
    Fixes issue #259.

 src/orca/scripts/web/script.py           |  4 ++--
 src/orca/scripts/web/script_utilities.py | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index ad24f1e08..c08475d5e 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -1735,10 +1735,10 @@ class Script(default.Script):
             msg = "WEB: Caret moved due to native caret navigation."
             debug.println(debug.LEVEL_INFO, msg, True)
 
-        elif event.source.getRole() in [pyatspi.ROLE_ENTRY, pyatspi.ROLE_SPIN_BUTTON] \
+        elif self.utilities.isTextField(event.source) \
            and event.source.getState().contains(pyatspi.STATE_FOCUSED) \
            and event.source != orca_state.locusOfFocus:
-            msg = "WEB: Focused entry is not (yet) the locus of focus."
+            msg = "WEB: Focused text field is not (yet) the locus of focus."
             debug.println(debug.LEVEL_INFO, msg, True)
             notify = force = handled = True
 
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index e3b867937..c8f2f7b5c 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -2558,6 +2558,24 @@ class Utilities(script_utilities.Utilities):
         displayStyle = self._getDisplayStyle(obj)
         return "inline" in displayStyle
 
+    def isTextField(self, obj):
+        try:
+            role = obj.getRole()
+        except:
+            msg = "ERROR: Exception getting role for %s" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return False
+
+        if role in [pyatspi.ROLE_ENTRY,
+                    pyatspi.ROLE_PASSWORD_TEXT,
+                    pyatspi.ROLE_SPIN_BUTTON]:
+            return True
+
+        if role == pyatspi.ROLE_COMBO_BOX:
+            return self.isEditableComboBox(obj)
+
+        return False
+
     def isFirstItemInInlineContentSuggestion(self, obj):
         suggestion = pyatspi.findAncestor(obj, self.isInlineSuggestion)
         if not (suggestion and suggestion.childCount):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]