"Focusable elements should have interactive semantics" when `:focus` is used to toggle a popup.

I'm working on adding a feature to my site where you can see what song I'm listening to via a small widget. In order to show what the name, album, and artists of the song, I added a popup which displays this information. It can be brought up by hovering the element or focusing onto it. In order to make this work without JS, I just use :focus/:hover with display:none/display:block, and set a [tabindex=0] so it can be focused. When I check my accessibility in Firefox's built in accessibility checker, I get a warning:
Keyboard
⚠️ Focusable elements should have interactive semantics.
Learn more
Is this warning something I should ignore as a false positive, or is there something I need to fix? Here's a link to my code, and here's a link to the relevant file. (It's an astro site) I'm aware theres still some issues w the aria stuff on the now playing specifically (too many divs) but if you see something that needs fixing please point it out lol! Thanks in advance !!
20 Replies
ἔρως
ἔρως2w ago
a div element isn't an interactible element
Kai / Nico / Jen / Alex
yeah but i used [tabindex] to give it focus, and css to make it do things when focused. im trying to avoid relying on js but i dont think there would be an element better suited (in terms of functionality. obviously it needs to have better aria than it does currently) to clarify: my code works i just want to make sure its properly accessible lol
ἔρως
ἔρως2w ago
that doesn't change the fact it isn't interactible why are you making it focusable anyways?
Kai / Nico / Jen / Alex
so that keyboard users can see the popup (since its not visible otherwise lol) what do u mean by interactible? like it doesnt do anything orrr
ἔρως
ἔρως2w ago
like: you can't interact with it in any way, shape or form
Kai / Nico / Jen / Alex
not by default, but thats why i added the tab index, so it CAN be focused to reveal things
ἔρως
ἔρως2w ago
you can't interact with it even if you focus it
Kai / Nico / Jen / Alex
as in like. trigger a click event do you mean
ἔρως
ἔρως2w ago
all elements handle clicks
ἔρως
ἔρως2w ago
and other things too
Kai / Nico / Jen / Alex
im confused what you mean by "its not interactible" then
ἔρως
ἔρως2w ago
it's not an input or any of the elements in the list
Kai / Nico / Jen / Alex
is it that in my code it doesnt do anything except absorb focus? like when focused theres no click event or anything, it just has [tabindex]?
ἔρως
ἔρως2w ago
yes, it just absorbs the focus and that's it
Kai / Nico / Jen / Alex
how would you propose i reveal the popover to the user via keyboard navigation without using focus instead then? cause i can't think of a better way to do it off the top of my head lol
ἔρως
ἔρως2w ago
you're using it on the wrong element add a button that does the revealing
Kai / Nico / Jen / Alex
yeah that would make. a lot more sense actually lmao tysm !!
ἔρως
ἔρως2w ago
you're welcome
Kevin Powell
Kevin Powell2w ago
not sure how you're handling it, but to properly connect them, a button + popover hint might be a good solution https://mdn.github.io/dom-examples/popover-api/popover-hint/

Did you find this page helpful?