focus() doesn't work on mobile device

XMLWordPrintable

    • ZK 8.5.2 S1
    • None

      Steps to Reproduce

      1. visit the zul with safari on ipad (iOS 5.1.1) / iphone6s

      <zk xmlns:w="client">
          <textbox id="test"/>
          <button label="java focus" onClick="test.focus()"></button>
      </zk>
      

      2. click the button

      Current Result

      the textbox doesn't get the focus

      Expected Result

      the textbox gets the focus and virtual keyboard popup

      Debug Info

      • this issue doesn't happen on desktop browsers
      • ASUS zenfone doesn't have such issue.
      • safari on ipad (iOS 5.1.1) / iphone6s have such issue, so other Apple mobile devices might have

      Root Cause

      https://developer.apple.com/documentation/uikit/uiwebview/1617967-keyboarddisplayrequiresuseractio

      In mobile Safari, the user must explicitly tap the elements in the web view to display the keyboard.

      Workaround

      <button label="client focus" w:onClick="zk.Widget.$('$test').$n().focus();"></button>

            Assignee:
            rudyhuang
            Reporter:
            hawk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 1 day
                1d
                Remaining:
                Time Spent - 1 hour Remaining Estimate - 7 hours
                7h
                Logged:
                Time Spent - 1 hour Remaining Estimate - 7 hours
                1h