TLDR
I'm learning Electron. I have an HTML element <input type="text">, I can edit the text in it. After I do an alert, when i click the input element it shows no cursor, and pressing keys in the keyboard doesn’t change the text in the element. This doesn’t happen if I do the same in the browser, and I’m not sure if I’m doing something wrong.
Minimum, reproducible example
Setup
In an empty folder in a terminal write:
npm init # And leave the defaults
npm install --save-dev electron
Then create index.js:
const {app, BrowserWindow} = require("electron");
app.on('ready', () => {
let b = new BrowserWindow();
b.loadFile("index.html");
});
And index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test</title>
</head>
<body>
<input type="text">
<button onclick="alert('foo');">Hi</button>
</body>
</html>
Steps to reproduce
- On the terminal write
npx electron .to start the application. - Edit the text in the
input - Press the
Hibutton. - Close the dialog.
- Click the
inputelement.
The element doesn’t show a cursor, nor doesn’t it change to show that I’m editing it. Pressing keys in the keyboard doesn’t change the text in the input.
Clicking it multiple times selects the text, and it lets me delete it. But I’m unable to write new text.
Expected behaviour
Open index.html in the browser, and repeat the steps. In the browser the element shows a cursor, and I’m able to edit the text in it.
I’m not sure if I’m doing something wrong, or if this is actually the intended behaviour.
Here is the package.json if some information here helps:
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"electron": "^17.1.2"
}
}
Something weird that I noticed while testing it after posting is that if I minimize the window, and open it again, I’m able to edit the input. It happens too if I open and close the developer tools.

