[webkit-changes] [WebKit/WebKit] 7eae94: [iOS] Unable to focus phone number field in Takeou...

Wenson Hsieh noreply at github.com
Fri Feb 21 12:41:28 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7eae9413cc52a9fee6d2a50316c753e86aa4d5a5
      https://github.com/WebKit/WebKit/commit/7eae9413cc52a9fee6d2a50316c753e86aa4d5a5
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2025-02-21 (Fri, 21 Feb 2025)

  Changed paths:
    M Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h
    M Source/WebCore/dom/Element.cpp

  Log Message:
  -----------
  [iOS] Unable to focus phone number field in Takeout/Ele.me (饿了么) Alipay mini program when adding a new delivery address
https://bugs.webkit.org/show_bug.cgi?id=288201
rdar://145026254

Reviewed by Aditya Keerthi.

Add a new linked-on-or-after check to restore the order in which we dispatch the `focus` event and
notify the embedding client about the newly focused element, for apps linked on or before iOS 18.3.
In this particular case, this new ordering causes a certain telephone number field in the Ele.me
mini-program (in Alipay) to fail to show the keyboard when tapped. This phone number text field is
special because it's tagged with a `data-keyboard=number` DOM attribute, which the embedding context
(Alipay) handles in the following way:

1.  When the `focus` DOM event is dispatched for this text field, the page immediately calls `blur`
    on the text field, and posts a custom message to message handler in the app, which tells it to
    show a custom input view: `updateNativeKeyBoardInput`.

2.  In response to receiving this message, a `H5KeyboardField` (`UITextField` subclass) is unhidden,
    made first responder, and then positioned over the input field in the DOM, such that the text in
    this native field appears as if it were part of the web content. The input view used for this
    `H5KeyboardField` is custom — in this particular case, their own version of a numeric (0-9)
    keyplane.

    Crucially, however, this step appears to only happen if `-reloadInputViews` has been called on
    the content view *right before* receiving this message — on shipping versions of iOS, this
    happens as a result of handling the `WebPageProxy_ElementDidFocus` IPC message.

3.  As the user types, the value of the phone number field in the DOM is updated to reflect the text
    in the native `H5KeyboardField`.

Since the order in which this IPC is dispatched and when the `focus` DOM event is dispatched was
inverted in https://commits.webkit.org/287924@main, step (2) no longer works properly, because the
UI process never receives the focused element information for an element that is immediately blurred
upon being focused. This new behavior is generally correct, so we can avoid this binary
incompatibility by deploying a linked-on-or-after check guarding this new behavior.

Note that Alipay has several ways to fix this issue with the new ordering, including:

- Using `inputmode=none` on the input field instead of blurring it.
- Override `-[WKWebView inputView]` to show their own custom view instead of blurring the field.
- Calling `blur()` on a zero-delay timer.

* Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h:
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::dispatchFocusEvent):

Add the new linked-on-or-after check here, cached behind a global static variable.

Canonical link: https://commits.webkit.org/290818@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list