Skip to content

Commit b4c86b7

Browse files
Merge 879c03e into f4955df
2 parents f4955df + 879c03e commit b4c86b7

3 files changed

Lines changed: 64 additions & 1 deletion

File tree

source/NVDAObjects/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,18 @@ def event_mouseMove(self,x,y):
11781178
speech.speakText(text)
11791179

11801180
def event_stateChange(self):
1181-
if self is api.getFocusObject():
1181+
# Automatically announce state changes for certain objects.
1182+
inFocus = (
1183+
# this is the current focus:
1184+
# E.g. announcing the checked state of a checkbox
1185+
self is api.getFocusObject()
1186+
# this is a focuse ancestor:
1187+
# Including the ancestors supports scenarios such as
1188+
# when pressing a focused button changes the state of an ancestor container,
1189+
# E.g. a button inside a column header that changes the sorting state of the column (#10890)
1190+
or any(self is obj for obj in api.getFocusAncestors())
1191+
)
1192+
if inFocus:
11821193
speech.speakObjectProperties(self, states=True, reason=controlTypes.OutputReason.CHANGE)
11831194
braille.handler.handleUpdate(self)
11841195
vision.handler.handleUpdate(self, property="states")

tests/system/robot/chromeTests.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,3 +2089,52 @@ def test_focus_mode_on_focusable_read_only_lists():
20892089
]),
20902090
message="focus mode - focus list item and turn on focus mode"
20912091
)
2092+
2093+
2094+
def test_i10890():
2095+
"""
2096+
Ensure that sort state is announced on a column header when changed with inner button
2097+
"""
2098+
spy = _NvdaLib.getSpyLib()
2099+
# Chrome sometimes exposes tables as clickable, sometimes not.
2100+
# This test does not need to know, so disable reporting of clickables.
2101+
spy.set_configValue(["documentFormatting", "reportClickable"], False)
2102+
testFile = os.path.join(ARIAExamplesDir, "grid", "datagrids.html")
2103+
_chrome.prepareChrome(
2104+
f"""
2105+
<iframe src="{testFile}"></iframe>
2106+
"""
2107+
)
2108+
# Jump to the Example 2 heading
2109+
_chrome.getSpeechAfterKey("3")
2110+
actualSpeech = _chrome.getSpeechAfterKey("3")
2111+
_asserts.strings_match(
2112+
actualSpeech,
2113+
SPEECH_SEP.join([
2114+
"Example 2: Sortable Data Grid With Editable Cells",
2115+
"heading",
2116+
"level 3",
2117+
])
2118+
)
2119+
# Jump to the table
2120+
actualSpeech = _chrome.getSpeechAfterKey("t")
2121+
_asserts.strings_match(
2122+
actualSpeech,
2123+
SPEECH_SEP.join([
2124+
"Transactions January 1 through January 7",
2125+
"table",
2126+
"with 8 rows and 6 columns",
2127+
"row 1",
2128+
"column 1",
2129+
"sorted ascending",
2130+
"Date",
2131+
"button",
2132+
])
2133+
)
2134+
# Press the button
2135+
actualSpeech = _chrome.getSpeechAfterKey("space")
2136+
# and ensure that the new sort state is spoken.
2137+
_asserts.strings_match(
2138+
actualSpeech,
2139+
"sorted descending",
2140+
)

tests/system/robot/chromeTests.robot

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,6 @@ focus mode is turned on on focused read-only list item
138138
ARIA details role
139139
[Documentation] Test aria details roles being announced on discovery
140140
test_mark_aria_details_role
141+
i10890
142+
[Documentation] Test sort state is announced on column header when changed with inner button
143+
test_i10890

0 commit comments

Comments
 (0)