Tab key not working in popup in chrome extension
Asked Answered
C

2

9

I have created a chrome extension that has a popup with the following HTML markup in it:

<html>
<head>
<style>
body {
font-family: 'Open Sans',arial,sans-serif;
background-color: #E5E5E5;
font-size: 13px;
text-shadow: 0px 1px rgba(255, 255, 255, 0.5);
}
</style>
</head>
<script type="text/javascript">function sendRequest(s,r){
chrome.tabs.getSelected(null, function(tab) {
  chrome.tabs.sendRequest(tab.id, {search:s , replace:r}, function(response) {
    console.log(response.farewell);
  });
});
};
</script>
<body>

<label for="search">Search for</label><input name="search" id="search"></input>
<label for="replace">Replace with</label><input name="replace" id="replace"></input>
<button onclick="var s=document.getElementById('search').value;var r=document.getElementById('replace').value;sendRequest(s,r);">Go</button>
</body>
</html>

When I open the popup, select the first input field and then press the tab key, the input field loses focus but the second one does not gain focus.

If I then select the first one again and press tab once more, the second field gains focus. Pressing again makes the button gain focus and pressing a third time makes the first field gain focus once more.

Does anyone know why the first tab key press would not work?

Crud answered 30/1, 2012 at 21:2 Comment(7)
Unfortunatley I cant answer your question (thats really odd I wonder whats going on?) but heres a couple of pointers to do with tabbing. If you care about the tabbing stuff you should use tabindex, you should make something focus on page load and you should put in something invisible as your last tabindex that shifts the focus to the first element or it goes into the browser stuff. Heres an example of what the page looks like with the added info.. pastebin.com/2izkBt7g (works in page, not popup?) also, when posting probs with Chrome its a good idea to say what version your testing in.Brunswick
Hi Wladimir. Thanks very much for the tip. I've implemented this in my popup and I'm using Chrome 17.0.963.46 beta-m. Unfortunately, the cursor still disappears after the first tab key press. I can successfully get the 2nd tabindex to be selected upon loading the popup, but the 2nd key press results in a missing cursor once again. Do you think this could just be a bug with Chrome?Crud
It worked for me, in the stable version. The cursor doesn't disappear, everything is working exactly the way you'd expect it to.Kibler
It must be related to the most recent version of Chrome as it is also working for me in version 16.0.912.77 m.Crud
It has to be related to something introduced by chrome. As I am positive that my extension worked with the tab key before the newest. As of 18 beta-m its still broken so not sure what to do about it...Cheyenne
Please, please, could an extension author who has code that demonstrates this issue file a bug report with the Chrome team? Other extensions have the same problem, but it's not clear to me that the Chrome devs know about it...?Pusillanimity
I have also added comment at code.google.com/p/chromium/issues/…. I would request you to go and vote for the issue so it can gain high priority.Java
D
6

See Chrome bug report here: http://code.google.com/p/chromium/issues/detail?id=122352

EDIT: Fix is currently implemented in Canary build 26.0.1408.1 (Official Build 181614) at the time of this edit.

Dittography answered 15/5, 2012 at 20:20 Comment(1)
Bug is back, hasn't been refixed yet: code.google.com/p/chromium/issues/detail?id=122352Coleslaw
S
0

This appears to be working in Chrome Version 32.0.1700.76 m.

I have never seen it working properly for my TxtPad extension, but today it worked after the chrome update.

Hope it remains like that now.

Slavin answered 20/1, 2014 at 21:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.