In my project I have a list of 'result items' which can be favourited and then they appear on in a favourites column to the side of the page.
To allow keyboard users easy access, I have created a hidden cta which allows them to skip directly to their favourited item, without having to tab through all the result items first.
I only want this cta to be visible when it is tabbed to. My understanding is that :focus-visible would enable this. However, for some reason, it's not working for me. My HTML and CSS look like:
.sr-only-focusable {
position: absolute;
visibility: hidden;
left: 56%;
top: rem(65);
border-radius: 5px;
border: 1px solid #d7d7d7;
background-color: $white;
padding: 1rem 2rem;
z-index: 10;
}
.sr-only-focusable:focus-visible {
visibility: visible;
}
<div class="sr-only-focusable">
<button tabindex="0" @click="skipToShortlist">Skip To Shortlist</button>
</div>
Could anyone help me figure out where i'm going wrong?
Thanks in advance