Commit 670f03c8 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Fixes braille textarea output for empty lines

When arrowing by line (up/down) through a text area and encountering a blank line in braille

before:
- braille would not correctly clear the previous line contents
- e.g.
"Testing testing

one"


"Testing testing" would remain displayed even though the caret was on the second (blank) line.

after:
Arrowing by line results in
- blank display
- a blinking cursor over the first cell

Change-Id: I1cd770644f78c60e2c4cf4d074da5c048aff9e52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2085155
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746863}
parent 858d21c3
...@@ -56,7 +56,6 @@ editing.TextEditHandler = class { ...@@ -56,7 +56,6 @@ editing.TextEditHandler = class {
// A rich text field is one where selection gets placed on a DOM // A rich text field is one where selection gets placed on a DOM
// descendant to a root text field. This is one of: // descendant to a root text field. This is one of:
// - content editables (detected via richly editable state) // - content editables (detected via richly editable state)
// - the node is a textarea
// //
// The only other editables we expect are all single line (including those // The only other editables we expect are all single line (including those
// from ARC++). // from ARC++).
...@@ -245,6 +244,14 @@ const AutomationEditableText = class extends ChromeVoxEditableTextBase { ...@@ -245,6 +244,14 @@ const AutomationEditableText = class extends ChromeVoxEditableTextBase {
} }
const startIndex = this.start - lineStart; const startIndex = this.start - lineStart;
const endIndex = this.end - lineStart; const endIndex = this.end - lineStart;
// If the line is not the last line, and is empty, insert an explicit line
// break so that braille output is correctly cleared and has a position for
// a caret to be shown.
if (lineText == '' && lineIndex < this.lineBreaks_.length - 1) {
lineText = '\n';
}
const spannable = new Spannable(lineText, new Output.NodeSpan(this.node_)); const spannable = new Spannable(lineText, new Output.NodeSpan(this.node_));
ChromeVox.braille.write( ChromeVox.braille.write(
new NavBraille({text: spannable, startIndex, endIndex})); new NavBraille({text: spannable, startIndex, endIndex}));
......
...@@ -1361,3 +1361,23 @@ TEST_F('ChromeVoxEditingTest', 'SelectAll', function() { ...@@ -1361,3 +1361,23 @@ TEST_F('ChromeVoxEditingTest', 'SelectAll', function() {
input.focus(); input.focus();
}); });
}); });
TEST_F('ChromeVoxEditingTest', 'TextAreaBrailleEmptyLine', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree('<textarea></textarea>', function(root) {
const textarea = root.find({role: RoleType.TEXT_FIELD});
this.listenOnce(textarea, 'focus', function() {
this.listenOnce(textarea, 'valueChanged', function() {
mockFeedback.call(this.press(38 /* up arrow */)).expectBraille('\n');
mockFeedback.call(this.press(38 /* up arrow */)).expectBraille('two');
mockFeedback.call(this.press(38 /* up arrow */)).expectBraille('one');
mockFeedback.call(this.press(38 /* up arrow */)).expectBraille('\n');
mockFeedback.call(this.press(38 /* up arrow */))
.expectBraille('test mled')
.replay();
});
});
textarea.focus();
textarea.setValue('test\n\none\ntwo\n\nthree');
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment