Skip to content

Commit

Permalink
Ensure that labels explicitly set on divs and spans are reported in b…
Browse files Browse the repository at this point in the history
…raille and speech (#8886)

* Ensure that labels explicitly set by the web author on nodes such as divs and spans (that don't usually get reported) are shown in browseMode in both speech and braille.

* Update what's new.
  • Loading branch information
michaelDCurran authored Oct 29, 2018
1 parent ceafcdd commit fd24d81
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
8 changes: 7 additions & 1 deletion source/braille.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,16 @@ def getControlFieldBraille(info, field, ancestors, reportStart, formatConfig):
current=field.get('current', None)
placeholder=field.get('placeholder', None)
roleText=field.get('roleText')
name=field.get('name')
alwaysReportName=field.get('alwaysReportName')

if presCat == field.PRESCAT_LAYOUT:
text = []
# The only item we report for these fields is clickable, if present.
# Always braille the name of a field if it is forced.
# This is for the fallback case where a div or a span (which has no other presentation) has its name reported if explicitly set by the author using aria-label etc.
if alwaysReportName and name and field.get("_startOfNode"):
text.append(name)
# report clickable if present.
if controlTypes.STATE_CLICKABLE in states:
text.append(getBrailleTextForProperties(states={controlTypes.STATE_CLICKABLE}))
if current:
Expand Down
4 changes: 4 additions & 0 deletions source/browseMode.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,8 @@ def getControlFieldSpeech(self, attrs, ancestorAttrs, fieldType, formatConfig=No
name=attrs.get('name')
if name and attrs.getPresentationCategory(ancestorAttrs,formatConfig,reason) is None:
textList.append(name)
# As the name is being explicitly reported along with the landmark, we must ensure that it is not reported again generically
attrs['alwaysReportName']=False
if landmark == "region":
# The word landmark is superfluous for regions.
textList.append(aria.landmarkRoles[landmark])
Expand All @@ -1082,6 +1084,8 @@ def getControlFieldBraille(self, field, ancestors, reportStart, formatConfig):
# Ensure that the name of the field gets presented even if normally it wouldn't.
name=field.get('name')
if name and field.getPresentationCategory(ancestors,formatConfig) is None:
# As the name is being explicitly reported along with the landmark, we must ensure that it is not reported again generically
field['alwaysReportName']=False
textList.append(name)
if landmark == "region":
# The word landmark is superfluous for regions.
Expand Down
12 changes: 9 additions & 3 deletions source/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,10 @@ def getControlFieldSpeech(attrs,ancestorAttrs,fieldType,formatConfig=None,extraD

presCat=attrs.getPresentationCategory(ancestorAttrs,formatConfig, reason=reason)
childControlCount=int(attrs.get('_childcontrolcount',"0"))
if reason==controlTypes.REASON_FOCUS or attrs.get('alwaysReportName',False):
alwaysReportName=attrs.get('alwaysReportName',False)
alwaysReportDescription=attrs.get('alwaysReportDescription',False)
isBlock=attrs.get('_isBlock',False)
if reason==controlTypes.REASON_FOCUS or alwaysReportName:
name=attrs.get('name',"")
else:
name=""
Expand Down Expand Up @@ -1225,14 +1228,17 @@ def getControlFieldSpeech(attrs,ancestorAttrs,fieldType,formatConfig=None,extraD
# Special cases
elif not speakEntry and fieldType in ("start_addedToControlFieldStack","start_relative"):
out = []
# Always speak the name of a field if it is forced.
# This is for the fallback case where a div or a span (which has no other presentation) has its name announced if explicitly set by the author using aria-label etc.
if alwaysReportName and nameText:
out.append(nameText)
if not extraDetail and controlTypes.STATE_CLICKABLE in states:
# Clickable.
out.append(getSpeechTextForProperties(states=set([controlTypes.STATE_CLICKABLE])))
if ariaCurrent:
out.append(ariaCurrentText)
return CHUNK_SEPARATOR.join(out)
else:
return ""
return ""

def getFormatFieldSpeech(attrs,attrsCache=None,formatConfig=None,reason=None,unit=None,extraDetail=False , initialFormat=False, separator=CHUNK_SEPARATOR):
if not formatConfig:
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ What's New in NVDA
- NVDA no longer fails to track focus in File Explorer and other applications using UI Automation when another app is busy (such as batch processing audio). (#7345)
- In ARIA menus on the web, the Escape key will now be passed through to the menu and no longer turn off focus mode unconditionally. (#3215)
- NVDA no longer refuses to report the focus on web pages where the new focus replaces a control that no longer exists. (#6606, #8341)
- In BrowseMode, NVDA will now always report labels on divs and spans explicitly set by the web author. (#8886)


== Changes for Developers ==
Expand Down

0 comments on commit fd24d81

Please sign in to comment.