Repository: nvaccess/nvda

Issue:
Screen Reader is not announcing associated information.
**Test Environment**
OS: Windows_11
Version: 21H2
OS Build: 22000.795
Browser: Version 103.0.1264.71 (Official Build) (64-bit)
URL: data:text/html,%3cbutton%3eoutter%20target1%3c/button%3e%3cnav%20aria-labelledby=%22nav-1%22%3e%3ch2%20id=%22nav-1%22%3eTest%20navigation%3c/h2%3e%3cbutton%3einner%20target%3c/button%3e%3c/nav%3e

**Repro Steps:**
1. Visit this URL data:text/html,%3cbutton%3eoutter%20target1%3c/button%3e%3cnav%20aria-labelledby=%22nav-1%22%3e%3ch2%20id=%22nav-1%22%3eTest%20navigation%3c/h2%3e%3cbutton%3einner%20target%3c/button%3e%3c/nav%3e

https://user-images.githubusercontent.com/93735775/183353955-e3dbf693-9827-401e-a28d-e579588c7d4a.mp4


2. Hit the b key to focus the button in the region. arrowing also works but the button skips the header.
3. Observe what NVDA syas.
4. Use object navigation to escape the region.

**Actual Behavior**
Upon entering, nvda does not read the labelledby but it does read the labelledby when I touch the node with object nav.

**Expected Behavior**
The heading is read.



Discussion:
Hello,

What I understand from your bug report is: you would like NVDA to announce it entered into a "nav" section with the label attached to the nav section, isn't it?

If yes, please update your bug accordingly to make it clearer.
Closing as duplicate of #13307
Note: this video appears to be using narrator

Resolving patch:
diff --git a/source/speech/speech.py b/source/speech/speech.py
--- a/source/speech/speech.py
+++ b/source/speech/speech.py
@@ -2032,9 +2032,15 @@ def getControlFieldSpeech(  # noqa: C901
 		nameSequence
 		and reason in [OutputReason.FOCUS, OutputReason.QUICKNAV]
 		and fieldType == "start_addedToControlFieldStack"
-		and role in (controlTypes.Role.GROUPING, controlTypes.Role.PROPERTYPAGE)
+		and role in (
+			controlTypes.Role.GROUPING,
+			controlTypes.Role.PROPERTYPAGE,
+			controlTypes.Role.LANDMARK,
+			controlTypes.Role.REGION,
+		)
 	):
 		# #10095, #3321, #709: Report the name and description of groupings (such as fieldsets) and tab pages
+		# #13307: report the label for landmarks and regions
 		nameAndRole = nameSequence[:]
 		nameAndRole.extend(roleTextSequence)
 		types.logBadSequenceTypes(nameAndRole)


Test patch:
diff --git a/tests/system/robot/chromeTests.py b/tests/system/robot/chromeTests.py
--- a/tests/system/robot/chromeTests.py
+++ b/tests/system/robot/chromeTests.py
@@ -2275,3 +2275,78 @@ def test_ARIASwitchRole():
 		]),
 		message="Report focus",
 	)
+
+
+def test_i13307():
+	"""
+	Even if (to avoid duplication) NVDA may choose to not speak a landmark or region's label
+	when arrowing into a landmark or region with an aria-labelledby,
+	it should still speak the label when junping inside the landmark or region
+	from outside using quicknav or focus.
+	"""
+	_chrome.prepareChrome(
+		"""
+		<p>navigation landmark with aria-label</p>
+		<nav aria-label="label">
+			<button>inner element</button>
+		</nav>
+		<p>Navigation landmark with aria-labelledby</p>
+		<nav aria-labelledby="innerHeading1">
+			<h1 id="innerHeading1">labelled by</h1>
+			<button>inner element</button>
+		</nav>
+		<p>Region with aria-label</p>
+		<section aria-label="label">
+			<button>inner element</button>
+		</section>
+		<p>Region with aria-labelledby</p>
+		<section aria-labelledby="innerHeading2">
+			<h1 id="innerHeading2">labelled by</h1>
+			<button>inner element</button>
+		</section>
+		"""
+	)
+	actualSpeech = _chrome.getSpeechAfterKey("tab")
+	_asserts.strings_match(
+		actualSpeech,
+		SPEECH_SEP.join([
+			"label",
+			"navigation landmark",
+			"inner element",
+			"button",
+		]),
+		message="jumping into landmark with aria-label should speak label",
+	)
+	actualSpeech = _chrome.getSpeechAfterKey("tab")
+	_asserts.strings_match(
+		actualSpeech,
+		SPEECH_SEP.join([
+			"labelled by",
+			"navigation landmark",
+			"inner element",
+			"button",
+		]),
+		message="jumping into landmark with aria-labelledby should speak label",
+	)
+	actualSpeech = _chrome.getSpeechAfterKey("tab")
+	_asserts.strings_match(
+		actualSpeech,
+		SPEECH_SEP.join([
+			"label",
+			"region",
+			"inner element",
+			"button",
+		]),
+		message="jumping into region with aria-label should speak label",
+	)
+	actualSpeech = _chrome.getSpeechAfterKey("tab")
+	_asserts.strings_match(
+		actualSpeech,
+		SPEECH_SEP.join([
+			"labelled by",
+			"region",
+			"inner element",
+			"button",
+		]),
+		message="jumping into region with aria-labelledby should speak label",
+	)
diff --git a/tests/system/robot/chromeTests.robot b/tests/system/robot/chromeTests.robot
--- a/tests/system/robot/chromeTests.robot
+++ b/tests/system/robot/chromeTests.robot
@@ -144,3 +144,6 @@ i10890
 ARIA switch role
 	[Documentation]	Test aria switch control has appropriate role and states in browse mode and when focused
 	test_ARIASwitchRole
+i13307
+	[Documentation]	ensure aria-labelledby on a landmark or region is automatically spoken when jumping inside from outside using focus in browse mode
+	test_i13307