<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - WKActionSheet tries to present on wrong view controller"
   href="https://bugs.webkit.org/show_bug.cgi?id=157431">157431</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>WKActionSheet tries to present on wrong view controller
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>Safari 9
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>iOS
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>iOS 9.3
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>WebKit2
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>kevin&#64;sb.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When WKActionSheet is presented, it uses `[[_sheetDelegate hostViewForSheet].window rootViewController]` as the view controller to present from. But this doesn't work if the webview is actually inside a modally-presented view controller. This results in the sheet never showing and the following logged to the console:

Warning: Attempt to present &lt;WKActionSheet: 0x7fbdac077a00&gt; on &lt;RootViewController: 0x7fbda8d7b340&gt; whose view is not in the window hierarchy!

I imagine there's also issues with the rotation behavior, since it looks like it's supposed to dismiss itself and re-present after rotation.

The correct fix is to replace -hostViewForSheet with a method that returns the host UIViewController instead, but if that's problematic a quick fix would be to walk the presentedViewController chain to find the leaf controller and present on that (but this approach will have issues with view controllers that aren't fullscreen).</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>