electron: [Bug]: BrowserView elements do not retain input focus between BrowserWindow blur/focus
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a feature request that matches the one I want to file, without success.
Electron Version
12.0.1
What operating system are you using?
Windows
Operating System Version
10
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
When I’m focused in a BrowserView, I expect that alt+tabbing away, and alt+tabbing back, will keep focus in the BrowserView
Actual Behavior
Focus is lost, and I have to click back into the BrowserView
Testcase Gist URL
No response
Additional Information
No response
This is a continuation of this closed issue concerning webview, though it seems like this works fine for webview. Only BrowserView have this problem.
- start the app below and focus in the google input field
- alt tab away and alt tab back
- focus isn’t in the input field (in fact, it goes back to the main input element)
main.js:
const {app, BrowserWindow, BrowserView} = require('electron');
app.on('ready', () => {
const mainWindow = new BrowserWindow();
const view = new BrowserView();
view.setBounds({x: 0, y: 50, width: 800, height: 550});
mainWindow.setBrowserView(view);
mainWindow.loadFile(__dirname + "/index.html")
view.webContents.loadURL("https://google.com");
view.webContents.openDevTools({mode: "detach"}); // seems like this is required for BV to load the page for wrhatever reason
});
index.html:
<html>
<head></head>
<body>
this is an input in index.html:<br/>
<input></input>
<br/>
</body>
</html>
I’m having to work around it by intercepting the focus event of the BrowserWindow and explicitly focus the BrowserView’s WebContents.

About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 7
- Comments: 23 (2 by maintainers)
+1
Still an issue, here too. Debian 11, Cinnamon, x11.