I’ve come a bit stuck this afternoon with a bug in my web application in the latest version of Opera.
Usually, it is possible to remove elements from the markup’s tab-index flow by giving it the attribute:
tabindex="-1"
This means that when someone comes to the page and starts hitting their ‘tab’ key they will traverse the anchors/inputs in the document but those elements with -1 assigned will be ignored.
However, Opera’s spatial navigation flow still allows users to access those elements via their keyboard.
Does anybody know of an alternate way of removing elements from Opera’s spatial navigation flow in the same way that elements can in other browsers using tab-key document traversal?
Specifically: removing anchors from being accessible via Opera rather than inputs.
The markup below gives a rudimentary example. In non-Opera browsers you can use the tab key to go through the list, but it skips links 3, 4, and 7 because they have tabindex = -1 set. In Opera using spatial navigation (Ctrl+down/up arrow) it will still focus on those links..
<html>
<head>
<style>
:focus{border: 1px dashed green}
</style>
</head>
<body>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#" tabindex="-1">Link 3 (tabindex -1)</a></li>
<li><a href="#" tabindex="-1">Link 4 (tabindex -1)</a></li>
<li><a href="#">Link 5</a></li>
<li><a href="#">Link 6</a></li>
<li><a href="#" tabindex="-1">Link 7 (tabindex -1)</a></li>
<li><a href="#">Link 8</a></li>
<li><a href="#">Link 9</a></li>
</ul>
</body>
</html>
I can’t find a nice way to do this. It’s possible to do an ugly hack like
<a onfocus="document.moveFocusDown()" tabindex="-1">but I would not recommend it because there isn’t a good way to figure out if the user wants to go up or down..well, you could listen for keyup and do it from there if a tabindex=-1 element is focused and the key is arrow up/down, I guess..I recommend you report a bug saying that spatnav should respect tabindex=”-1″ – IMO your code as-is is fine and it would make sense to change this on Opera’s side. I’m happy to kick the bug in the general direction of the right developers once you’ve reported it. (I work on testing and QA at Opera).