Bug 193040 - HTMLInputElement.select() doesn't work in iOS Safari
Summary: HTMLInputElement.select() doesn't work in iOS Safari
Status: RESOLVED DUPLICATE of bug 193758
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: Safari 12
Hardware: iPhone / iPad iOS 12
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-12-26 17:31 PST by shrpne
Modified: 2019-02-02 18:34 PST (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description shrpne 2018-12-26 17:31:50 PST
HTMLInputElement.select() doesn't work in iOS Safari. While in desktop Safari it works fine.
For now, it's only modern browser without the support of `.select()` method.
`.setSelectionRange()` or `selectionStart` with `selectionEnd` should be used as workaround.
Comment 1 Radar WebKit Bug Importer 2018-12-27 11:28:59 PST
<rdar://problem/46962874>
Comment 2 Chris Dumez 2019-01-02 14:29:09 PST
I can see there is not IOS specific code in our select implementation:
void HTMLTextFormControlElement::select(SelectionRevealMode revealMode, const AXTextStateChangeIntent& intent)
{
    // FIXME: We should abstract the selection behavior into an EditingBehavior function instead
    // of hardcoding the behavior using a macro define.
#if PLATFORM(IOS_FAMILY)
    // We don't want to select all the text on iOS. Instead use the standard textfield behavior of going to the end of the line.
    setSelectionRange(std::numeric_limits<int>::max(), std::numeric_limits<int>::max(), SelectionHasForwardDirection, revealMode, intent);
#else
    setSelectionRange(0, std::numeric_limits<int>::max(), SelectionHasNoDirection, revealMode, intent);
#endif
}

Clearly, we have an implementation of HTMLInputElement.select() on all platforms. However, the iOS implementation is a bit different for some reason.
Comment 3 Ryosuke Niwa 2019-02-02 18:30:55 PST
Wenson, didn't we just fix this behavior recently?
Comment 4 Wenson Hsieh 2019-02-02 18:34:11 PST
(In reply to Ryosuke Niwa from comment #3)
> Wenson, didn't we just fix this behavior recently?

Yep, in https://bugs.webkit.org/show_bug.cgi?id=193758!

(Sorry for the forward dupe — I probably should've found this existing bug before filing a new one).

*** This bug has been marked as a duplicate of bug 193758 ***