Repository: nvaccess/nvda

Issue:
NVDA skips button text at the end of the line
<!--
Please thoroughly read NVDA's wiki article on how to fill in this template, including how to provide the required files.
Issues may be closed if the required information is not present.
https://github.com/nvaccess/nvda/wiki/Github-issue-template-explanation-and-examples
-->

### Steps to reproduce:
1. Load this into firefox:
```
data:text/html,<p>This is a test with text and buttons in a testing paragraph. This is a test. <button>Button label 1 with text</button></p>
```
2. Move to the beginning of the document and press f.
### Actual behavior:
NVDA says Button label 1 with  button
### Expected behavior:
NVDA should say Button label 1 with text button
### System configuration
#### NVDA installed/portable/running from source:
Installed
#### NVDA version:
Version: alpha-16885,2ed7dbae
#### Windows version:
Windows 10 Version 1809 (OS Build 17763.316)
#### Name and version of other software in use when reproducing the issue:
Firefox 65.0.2, Chrome Version 73.0.3683.75 (Official Build) (64-bit)
#### Other information about your system:

### Other questions
#### Does the issue still occur after restarting your PC?
Yes
#### Have you tried any other versions of NVDA?
No



Discussion:
@tspivey: Please update Firefox to 66.0 and try again. This issue could be a regression.
Upgrading Firefox didn't fix it.
Hi all,

I looked at this issue and know exactly what's happening, but don't have an idea on how to fix it efficiently.

Using the provided HTML snippet, I found that if you press the `B` key, NVDA will report the entire button content. But, the paragraph that contains it is long enough so that NVDA will split it in two lines. However, when setting up the quick navigation gesture for `formField`, we have `readUnit=textInfos.UNIT_LINE`, meaning that we will only report the first line of the `TextInfo` (obviously to avoid reporting a lengthy textbox content).

What we would need in the case of `formField` is to set this `readUnit` value based on the role of the queried control. Looking at the code in `speech.speakTextInfo()`, the way to retrieve this role seems slow, so I don't know if it's a good idea to use it inside the `TextInfoQuickNavItem.report()` for instance.

Any ideas?
In other words: If you increase the value in the option "Maximum Number of Characters on One Line" from "100" (default) to "120" in the Browse Mode NVDA Settings, this issue doesn't occur. Therefore I wasn't able to reproduce it because this value is always set to "120" on my systems. (I know that this is just a workaround.)

Resolving patch:
diff --git a/source/browseMode.py b/source/browseMode.py
--- a/source/browseMode.py
+++ b/source/browseMode.py
@@ -184,6 +184,10 @@ def isChild(self,parent):
 
 	def report(self,readUnit=None):
 		info=self.textInfo
+		# If we are dealing with a form field, ensure we don't read the whole content if it's an editable text.
+		if self.itemType == "formField":
+			if self.obj.role == controlTypes.ROLE_EDITABLETEXT:
+				readUnit = textInfos.UNIT_LINE
 		if readUnit:
 			fieldInfo = info.copy()
 			info.collapse()
@@ -613,8 +617,7 @@ def script_disablePassThrough(self, gesture):
 	# Translators: Input help message for a quick navigation command in browse mode.
 	prevDoc=_("moves to the previous form field"),
 	# Translators: Message presented when the browse mode element is not found.
-	prevError=_("no previous form field"),
-	readUnit=textInfos.UNIT_LINE)
+	prevError=_("no previous form field"))
 qn("list", key="l",
 	# Translators: Input help message for a quick navigation command in browse mode.
 	nextDoc=_("moves to the next list"),


Test patch: