So I am writing a simple webextension for Firefox. It uses a browserAction popup to get some data from the user. This data is entered into a textArea element. It would be convenient for the user if the textArea element had focus when the popup window appeared. I thought this would be a relatively simple matter of setting the focus in the popup's JavaScript, like so:
document.addEventListener('DOMContentLoaded', function(event) {
document.getElementById('texarea-id').focus();
});
However this doesn't work.
After some investigation (setting other visible changes in that function, and setting focus in other circumstances) it appears to me that the entire popup window does not have focus when opened.
Is there a way to fix this and get focus when a browserAction popup window is opened?