mozilla / positron

a experimental, Electron-compatible runtime on top of Gecko
Other
562 stars 64 forks source link

page loaded in <webview> doesn't respond to key events #82

Closed mykmelez closed 8 years ago

mykmelez commented 8 years ago

After loading a web page in the <webview> element in the sample browser app, the page doesn't respond to key events such as arrow key presses to scroll the page. Also, clicking on the page doesn't blur the location bar.

If the page has a text field, however, then clicking in that field will focus the field and blur the location bar. After which the page will start responding to key events. The default URL in the sample browser app, http://github.com/, happens to focus a text field on load, so it employs this workaround (albeit inadvertently).

mykmelez commented 8 years ago

It looks like the problem here is that calling focus() on the browser plugin node doesn't focus the node. WebViewImpl calls that method when a focus event is dispatched on the webview node https://github.com/mozilla/positron/blob/master/positron/electron/lib/renderer/web-view/web-view.js#L100-L103, but afterward, document.activeElement isn't that node. By contrast, when you click in a text field in the <webview> element (or after loading the default page, which focuses a text field), document.activeElement becomes the browser plugin node.