5

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?

Nick
  • 258
  • 1
  • 3
  • 7
  • The only thing I've found so far is having the user press Tab. See https://bugzilla.mozilla.org/show_bug.cgi?id=1324255 – Mottie Nov 28 '17 at 18:23
  • Yeah, I've been able to do that, still a bad UX. Thanks for the link I looked for something like that earlier, but couldn't find it. I was probably looking under the wrong version or something. – Nick Dec 09 '17 at 18:35
  • The bug has been fixed in Firefox 60 and later. – Smile4ever Jun 20 '18 at 08:37

0 Answers0