Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent SVG elements from gaining focus with tabs in IE11?

There is an inline SVG element among my HTML form elements. When I navigate through my elements with the Tab key, the SVG element gets focused, in IE11 only, even if the SVG element has the tabindex="-1" attribute set to every element inside it:

<svg width="20px" height="20px" tabindex="-1">
    <g tabindex="-1">
      <circle cx="8.5" cy="8.5" r="7.75" stroke="#999" stroke-width="1" tabindex="-1" />
      […]
    </g>
</svg>

To be sure that it's focusing on that element, I call document.activeElement in the console, and yes, it prints out the SVG thing.

Internet Explorer 11 should honor the negative value, as it does for other DOM elements, or should it not? What can I possibly do to prevent this?

like image 454
Alain Duchesneau Avatar asked Apr 01 '15 14:04

Alain Duchesneau


1 Answers

In case you missed it, the answer was commented:

tabindex is part of upcoming SVG2 and is not yet supported by IE11. Have a look at this question for a work-around.

The answer in that question recommends adding a focusable="false" attribute to the SVG element.

Thanks to @altocumulus

like image 158
Zachary Ryan Smith Avatar answered Nov 18 '22 19:11

Zachary Ryan Smith