I realized that tabindex=-1
doesn't work for <svg></svg>
elements. Is there a way to disable the focus
event for it? preventDefault
, stopPropagation
, stopImmediatePropagation
also do not work.
Asked
Active
Viewed 1.9k times
41

user229044
- 232,980
- 40
- 330
- 338

Shalom Aleichem
- 2,987
- 2
- 22
- 34
-
6FYI: This is a problem for IE 11 and MS Edge (all versions, currently through 13) and _for no other browser_. \*shakes fist\* Redmonndddd! – Alan H. Aug 11 '16 at 02:32
1 Answers
97
<svg focusable="false"></svg>
does this job.

Shalom Aleichem
- 2,987
- 2
- 22
- 34
-
9In my tests, the focus event never occurred on svg elements, not even with `focusable="true"`. It seems though that IE always allows selecting svg elements by keyboard navigation (with the tab key) unless the `focusable` attribute is explicitly set to "false". – GOTO 0 Dec 23 '13 at 18:19
-
3I'm confused. I can't find the `focusable` attribute in the SVG attribute index: https://www.w3.org/TR/SVG/attindex.html – Ralph David Abernathy Jan 13 '17 at 16:15
-
3If anyone's wondering if they can deprecate this workaround, as of Edge 38.14393, it's no longer necessary: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8090208/ – crowjonah May 24 '19 at 18:58