Skip to content

Commit 3db1450

Browse files
[Editing] Respect autocorrect="off" for Windows touch keyboard
The HTML autocorrect attribute (part of the WHATWG HTML standard) lets web authors disable autocorrect on <input> and <textarea> elements by setting autocorrect="off". The Windows touch keyboard ignores this and still autocorrects words. For example, typing "truf" + space yields "true " instead of preserving "truf ". To reproduce: 1. On a Windows touch-enabled device, open a page with <input autocorrect="off">. 2. Tap the field to bring up the touch keyboard. 3. Type a misspelled word (e.g. "truf") then tap space. 4. Observe: the touch keyboard replaces "truf" with "true". TSF's InputScope has no autocorrect field, so the touch keyboard is unaware of the page's preference and always autocorrects. Fix: snapshot the document buffer in TSFTextStore::RequestLock() before granting the lock. After the lock, if autocorrect="off" and committed text was replaced (not appended) without an active IME composition, revert the buffer and skip the commit. Normal typing and IME composition are unaffected. Bug: 487613498 Change-Id: Idcb07ce307a945d8f20250ca6c35d47e2bd8bbaf Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7609541 Reviewed-by: Jesse McKenna <jessemckenna@google.com> Commit-Queue: Pranav Modi <pranavmodi@microsoft.com> Reviewed-by: Dana Fried <dfried@chromium.org> Cr-Commit-Position: refs/heads/main@{#1594544}
1 parent bbbc4d0 commit 3db1450

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>autocorrect="off" should prevent touch keyboard autocorrection</title>
6+
<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-autocorrect">
7+
<meta name="assert" content="When autocorrect='off' is set on an input, textarea, or contenteditable element, the touch keyboard must not autocorrect user input.">
8+
<style>
9+
body {
10+
font-family: system-ui, sans-serif;
11+
max-width: 800px;
12+
margin: 20px auto;
13+
line-height: 1.6;
14+
}
15+
.test-case {
16+
border: 1px solid #ccc;
17+
border-radius: 8px;
18+
padding: 16px;
19+
margin: 16px 0;
20+
}
21+
.test-case h3 {
22+
margin-top: 0;
23+
}
24+
input, textarea {
25+
font-size: 16px;
26+
padding: 8px;
27+
width: 300px;
28+
}
29+
textarea {
30+
height: 60px;
31+
}
32+
[contenteditable] {
33+
font-size: 16px;
34+
padding: 8px;
35+
width: 300px;
36+
min-height: 40px;
37+
border: 1px solid #999;
38+
border-radius: 4px;
39+
}
40+
.instructions {
41+
background: #f0f4ff;
42+
border: 1px solid #b0c4ff;
43+
border-radius: 8px;
44+
padding: 16px;
45+
margin-bottom: 20px;
46+
}
47+
.pass-criteria {
48+
color: #006600;
49+
font-weight: bold;
50+
}
51+
</style>
52+
</head>
53+
<body>
54+
<h1>Manual Test: <code>autocorrect="off"</code> with Touch Keyboard</h1>
55+
56+
<div class="instructions">
57+
<h2>Prerequisites</h2>
58+
<ul>
59+
<li>A Windows device with a <strong>touch screen</strong> or the on-screen touch keyboard enabled.</li>
60+
<li>The touch keyboard must have autocorrect/text prediction enabled (this is the default).</li>
61+
</ul>
62+
<h2>Steps (repeat for each test case below)</h2>
63+
<ol>
64+
<li>Tap the input field to bring up the touch keyboard.</li>
65+
<li>Using the touch keyboard, type the misspelled word shown in each test case below.</li>
66+
<li>Tap the <strong>space bar</strong> on the touch keyboard to trigger word completion.</li>
67+
<li>Observe the text in the field.</li>
68+
</ol>
69+
<p><strong>Note:</strong> The touch keyboard's autocorrect behavior depends on
70+
its internal prediction model, which may vary by language, region, and
71+
learned user patterns. If the suggested misspelled words below do not
72+
trigger an autocorrection on your device, substitute any misspelled word
73+
that the touch keyboard does autocorrect. First confirm autocorrection
74+
is working using the <code>autocorrect="on"</code> test cases before
75+
testing the <code>autocorrect="off"</code> cases.</p>
76+
</div>
77+
78+
<h2>&lt;input&gt;</h2>
79+
80+
<div class="test-case">
81+
<h3>Test 1a: <code>&lt;input&gt;</code> with <code>autocorrect="on"</code></h3>
82+
<p>Type "truff" then press space using the touch keyboard.</p>
83+
<p><input type="text" autocorrect="on" placeholder="Type here using touch keyboard"></p>
84+
<p class="pass-criteria">PASS: The field contains "tuff " (autocorrect is active and corrects the input).</p>
85+
</div>
86+
87+
<div class="test-case">
88+
<h3>Test 1b: <code>&lt;input&gt;</code> with <code>autocorrect="off"</code></h3>
89+
<p>Type "recieve" then press space using the touch keyboard.</p>
90+
<p><input type="text" autocorrect="off" placeholder="Type here using touch keyboard"></p>
91+
<p class="pass-criteria">PASS: The field contains "recieve " (the typed text is preserved, not autocorrected to "receive ").</p>
92+
</div>
93+
94+
<h2>&lt;textarea&gt;</h2>
95+
96+
<div class="test-case">
97+
<h3>Test 2a: <code>&lt;textarea&gt;</code> with <code>autocorrect="on"</code></h3>
98+
<p>Type "vegen" then press space using the touch keyboard.</p>
99+
<p><textarea autocorrect="on" placeholder="Type here using touch keyboard"></textarea></p>
100+
<p class="pass-criteria">PASS: The field contains "vegan " (autocorrect is active and corrects the input).</p>
101+
</div>
102+
103+
<div class="test-case">
104+
<h3>Test 2b: <code>&lt;textarea&gt;</code> with <code>autocorrect="off"</code></h3>
105+
<p>Type "occured" then press space using the touch keyboard.</p>
106+
<p><textarea autocorrect="off" placeholder="Type here using touch keyboard"></textarea></p>
107+
<p class="pass-criteria">PASS: The field contains "occured " (the typed text is preserved, not autocorrected to "occurred ").</p>
108+
</div>
109+
110+
<h2>&lt;div contenteditable&gt;</h2>
111+
112+
<div class="test-case">
113+
<h3>Test 3a: <code>&lt;div contenteditable&gt;</code> with <code>autocorrect="on"</code></h3>
114+
<p>Type "definately" then press space using the touch keyboard.</p>
115+
<p><div contenteditable="true" autocorrect="on" role="textbox" aria-label="contenteditable input"></div></p>
116+
<p class="pass-criteria">PASS: The field contains "definitely " (autocorrect is active and corrects the input).</p>
117+
</div>
118+
119+
<div class="test-case">
120+
<h3>Test 3b: <code>&lt;div contenteditable&gt;</code> with <code>autocorrect="off"</code></h3>
121+
<p>Type "seperate" then press space using the touch keyboard.</p>
122+
<p><div contenteditable="true" autocorrect="off" role="textbox" aria-label="contenteditable input"></div></p>
123+
<p class="pass-criteria">PASS: The field contains "seperate " (the typed text is preserved, not autocorrected to "separate ").</p>
124+
</div>
125+
</body>
126+
</html>

0 commit comments

Comments
 (0)