Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: BrowserView elements do not retain input focus between BrowserWindow blur/focus #28163

Open
3 tasks done
pushkin- opened this issue Mar 12, 2021 · 15 comments
Open
3 tasks done

Comments

@pushkin-
Copy link

pushkin- commented Mar 12, 2021

Preflight Checklist

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.

  1. start the app below and focus in the google input field
  2. alt tab away and alt tab back
  3. 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.

focusretain

@bmnave
Copy link

bmnave commented Dec 3, 2021

+1 this is a major annoyance when using Mattermost on Linux with sloppy focus

@odusseys
Copy link

odusseys commented Sep 14, 2022

Having the same issue. This is extremely problematic for any apps which are text-input heavy, or which require keyboard interaction immediately after focusing the window. I cannot seem to find a workaround for this, as BrowserView's webContents.focus is not properly implemented and does nothing (on Mac OS here)

@pushkin-
Copy link
Author

pushkin- commented Oct 5, 2022

repros in Electron 21

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Jan 10, 2023
@bmnave
Copy link

bmnave commented Jan 10, 2023

Still an issue...

@github-actions github-actions bot removed the stale label Jan 11, 2023
@pwollny
Copy link

pwollny commented Mar 29, 2023

Still an issue, here too. Debian 11, Cinnamon, x11.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Jun 28, 2023
@pushkin-
Copy link
Author

bump

@github-actions github-actions bot removed the stale label Jun 29, 2023
@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@bmnave
Copy link

bmnave commented Sep 28, 2023

+1

@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@pushkin-
Copy link
Author

bump

@widavies
Copy link

same issue here

@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@bmnave
Copy link

bmnave commented May 14, 2024

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants