Skip to content

Commit fcd4d6f

Browse files
Merge e850725 into 9a30254
2 parents 9a30254 + e850725 commit fcd4d6f

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
@@ -1205,7 +1205,18 @@ def event_selection(self):
12051205
self.event_stateChange()
12061206

12071207
def event_stateChange(self):
1208-
if self is api.getFocusObject():
1208+
# Automatically announce state changes for certain objects.
1209+
inFocus = (
1210+
# this is the current focus:
1211+
# E.g. announcing the checked state of a checkbox
1212+
self is api.getFocusObject()
1213+
# this is a focuse ancestor:
1214+
# Including the ancestors supports scenarios such as
1215+
# when pressing a focused button changes the state of an ancestor container,
1216+
# E.g. a button inside a column header that changes the sorting state of the column (#10890)
1217+
or any(self is obj for obj in api.getFocusAncestors())
1218+
)
1219+
if inFocus:
12091220
speech.speakObjectProperties(self, states=True, reason=controlTypes.OutputReason.CHANGE)
12101221
braille.handler.handleUpdate(self)
12111222
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
@@ -2104,3 +2104,52 @@ def test_focus_mode_on_focusable_read_only_lists():
21042104
]),
21052105
message="focus mode - focus list item and turn on focus mode"
21062106
)
2107+
2108+
2109+
def test_i10890():
2110+
"""
2111+
Ensure that sort state is announced on a column header when changed with inner button
2112+
"""
2113+
spy = _NvdaLib.getSpyLib()
2114+
# Chrome sometimes exposes tables as clickable, sometimes not.
2115+
# This test does not need to know, so disable reporting of clickables.
2116+
spy.set_configValue(["documentFormatting", "reportClickable"], False)
2117+
testFile = os.path.join(ARIAExamplesDir, "grid", "datagrids.html")
2118+
_chrome.prepareChrome(
2119+
f"""
2120+
<iframe src="{testFile}"></iframe>
2121+
"""
2122+
)
2123+
# Jump to the Example 2 heading
2124+
_chrome.getSpeechAfterKey("3")
2125+
actualSpeech = _chrome.getSpeechAfterKey("3")
2126+
_asserts.strings_match(
2127+
actualSpeech,
2128+
SPEECH_SEP.join([
2129+
"Example 2: Sortable Data Grid With Editable Cells",
2130+
"heading",
2131+
"level 3",
2132+
])
2133+
)
2134+
# Jump to the table
2135+
actualSpeech = _chrome.getSpeechAfterKey("t")
2136+
_asserts.strings_match(
2137+
actualSpeech,
2138+
SPEECH_SEP.join([
2139+
"Transactions January 1 through January 7",
2140+
"table",
2141+
"with 8 rows and 6 columns",
2142+
"row 1",
2143+
"column 1",
2144+
"sorted ascending",
2145+
"Date",
2146+
"button",
2147+
])
2148+
)
2149+
# Press the button
2150+
actualSpeech = _chrome.getSpeechAfterKey("space")
2151+
# and ensure that the new sort state is spoken.
2152+
_asserts.strings_match(
2153+
actualSpeech,
2154+
"sorted descending",
2155+
)

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)