Bug 151019 - Text input autocorrect="off" attribute ignored on Mac
Summary: Text input autocorrect="off" attribute ignored on Mac
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: WebKit Nightly Build
Hardware: Mac OS X 10.11
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
: 215198 (view as bug list)
Depends on:
Blocks: 246344
  Show dependency treegraph
 
Reported: 2015-11-09 07:09 PST by Michael Bailey
Modified: 2022-10-11 09:38 PDT (History)
13 users (show)

See Also:


Attachments
Just for EWS (3.14 KB, patch)
2020-08-05 16:52 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Patch (20.40 KB, patch)
2020-08-10 15:37 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Bailey 2015-11-09 07:09:28 PST
Using the autocorrect="off" attribute does not seem to have any effect on desktop Safari. It works as specified here on mobile Safari: https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/Attributes.html#//apple_ref/doc/uid/TP40008058-autocorrect

STR:
1. Open http://codepen.io/anon/pen/Lpgvya on mobile Safari.
2. Type a non-word (e.g. "baz") into the text field.
3. Note that there is no autocorrection offered.
4. Open the same page on desktop Safari.
5. Type a non-word (e.g. "baz") into the text field.
6. Note that the autocorrect popup appears (assuming it has not been disabled system-wide).

Tested on Safari 9.0.1 (11601.2.7.2), WebKit r192147, and iOS 9.1.
Comment 1 Wenson Hsieh 2020-08-05 16:40:58 PDT
*** Bug 215198 has been marked as a duplicate of this bug. ***
Comment 2 Wenson Hsieh 2020-08-05 16:42:11 PDT
Going to use this Bugzilla bug to track a fix for <rdar://problem/65061700>.
Comment 3 Wenson Hsieh 2020-08-05 16:52:24 PDT Comment hidden (obsolete)
Comment 4 Wenson Hsieh 2020-08-10 15:37:08 PDT
Created attachment 406334 [details]
Patch
Comment 5 Darin Adler 2020-08-10 16:07:28 PDT
Comment on attachment 406334 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406334&action=review

> Source/WebCore/ChangeLog:3
> +        Text input autocorrect="off" attribute ignored on Mac

I have no doubt that we want this on for the Mac, but wouldn't we also want this on all WebKit platforms that have automatic spelling correction for much the same reasons?
Comment 6 Wenson Hsieh 2020-08-10 16:12:18 PDT
(In reply to Darin Adler from comment #5)
> Comment on attachment 406334 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=406334&action=review
> 
> > Source/WebCore/ChangeLog:3
> > +        Text input autocorrect="off" attribute ignored on Mac
> 
> I have no doubt that we want this on for the Mac, but wouldn't we also want
> this on all WebKit platforms that have automatic spelling correction for
> much the same reasons?

I think we do! This patch merely supports the attribute on macOS, though. We will want separate bugs for the other platforms where we don’t support this attribute yet (which, as I understand, are Windows, GTK, and WPE).
Comment 7 Maciej Stachowiak 2020-08-11 10:22:12 PDT
We're adding this in part because it affects Twitter for any browser that does automatic spelling correction (as Mac Safari does, following macOS platform convention). For benefit of readers of this bug, here's a description of the Twitter issue, and my analysis of why "autocorrect" attribute support will fix it:

---------

Autocorrect in Twitter search field causes Twitter search to give confusingly wrong results. When you type something in the Twitter search field, a drop down menu appears with choices to click. If that something looks like a spelling or grammar error (as usernames often are), then we helpfully autocorrect it as soon as focus leaves the field. Clicking makes focus leave the field. And Twitter immediately pops off the menu when the correction is entered, and does this before processing the click, when then clicks through to a trend below.

Thus, you get a random trend search instead of the user you meant to click on.

## Sample steps to reproduce:
1. Go to https://twitter.com on a Mac in Safari
2. Click in the search field in the upper right
3. Type greendog (no space)
4. Click on a search result, e.g. the third, Green Dog Films

## Results:
The browser goes to a search page for a random trend. In the case of my screen recording, it goes to In-N-Out. WAT. 

## Other browsers:

Mac Chrome and MacFirefox don’t experience this bug because they do not seem to have autocorrect at all; they highlight what they think is a spelling error but don’t auto fix it.

iPad and iPhone Safari don’t experience the bug either. Why? Twitter loads the search field with many attributes to try to suppress autocorrect:

<input aria-activedescendant="typeaheadFocus-0.8970720798063739" aria-autocomplete="list" aria-label="Search query" aria-owns="typeaheadDropdown-3" autocapitalize="sentences" autocomplete="off" autocorrect="off" placeholder="Search Twitter" role="combobox" spellcheck="true" enterkeyhint="search" type="text" dir="auto" data-focusable="true" class="r-30o5oe r-1niwhzg r-17gur6a r-1yadl64 r-deolkf r-homxoj r-poiln3 r-7cikom r-1ny4l3l r-1sp51qo r-1lrr6ok r-1dz5y72 r-1ttztb7 r-13qz1uu" data-testid="SearchBox_Search_Input" value="greendog" aria-expanded="true">

I believe the one doing the trick on iOS is `autocorrect=off`. This is a nonstandard attribute that we support on iOS only. I suspect enabling it for macOS would fix this egregious Twitter bug.

In addition to that, we should probably standardize autocorrect=off, as this Twitter search bug demonstrates the use case.
Comment 8 Simon Fraser (smfr) 2020-08-11 10:32:07 PDT
google.com also has "autocorrect=off" on the main search field.
Comment 9 EWS 2020-08-11 12:46:02 PDT
Committed r265509: <https://trac.webkit.org/changeset/265509>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 406334 [details].