-
-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected focusing behavior using keyboard navigation #867
Comments
Hi; Something to note; this only happens for the Screen.Recording.2024-03-07.at.11.08.49.mov |
Could it be that |
Okay, had a look at a raw <script>
import { getContext } from 'svelte';
const ctx = getContext('iconCtx') ?? {};
export let size = ctx.size || '24';
export let role = ctx.role || 'img';
export let color = ctx.color || 'currentColor';
export let ariaLabel = 'accessibility';
</script>
<svg
width={size}
height={size}
{...$$restProps}
{role}
aria-label={ariaLabel}
on:click
on:keydown
on:keyup
on:focus
on:blur
on:mouseenter
on:mouseleave
on:mouseover
on:mouseout
viewBox="0 0 15 15"
fill={color}
xmlns="http://www.w3.org/2000/svg"
>
...
</svg> Thoughts:
Will keep looking around, and if there is a way to skip/overwrite this at |
Only have a bit of time right now, but if I open up dev tools on the calendar component and remove both the blur and focus events, the issue doesn't seem to happen. I made a little demo on Codepen. If you add a focus event listener to an SVG, it becomes focusable. If you comment out the event listener, it's no longer focusable. Still only on Chrome, but not Firefox or Safari. One short term fix in |
This tracks indeed.
My main concern about this, is that wouldn't we be forced to apply that patch/fix to every instance of the Let me play around and look into possible solutions for this; hope to arrive to an ideal one. 🙂 |
Hmm, this will definitely be problematic/annoying/unideal. |
Hey, @huntabyte There is a solution I found, but I'm not sure about the efficacy/accessibility/better implementation of it, and it would have to be implemented at Basically, it's just applying a negative
I am yet to try this specifically for our use case, but it works and brings up 2 solutions:
Wdyt? Whichever, lmt, and I'll try to see it through. |
I think opening up an issue/PR with svelte-radix would be best tbh. I don't imagine anyone expects that to be the default behavior of an SVG to receive focus. |
Didn't mean to close! |
Digging a bit more, apparently this is actually part of the SVG spec as an optional implementation detail, which Blink/Chrome adopted and I guess the other browser engines didn't.
The issue definitely comes from If
It looks like the core issue (Svelte setting essentially up inactive listeners) will be addressed in Svelte 5 anyways and that should be the preferred way moving forward to forward all listeners instead of guessing at the ones devs will care about. I can give a stab at addressing it in a PR with |
Closing as this is resolved when updating to the latest version of the icon pack. |
Describe the bug
If you focus on certain interactive elements using keyboard navigation, then move focus to the next focusable element, you'll find focus moves one level deeper into the same interactive element that is already focused.
This is confusing for those using keyboard navigation or assistive technologies as you would expect focus to move to the next interactive element.
It's made more confusing by the fact that you can't see the second focus ring in dark mode.
The issue only reproduces on Mac Chrome for me, but Firefox and Safari seem fine.
Reproduction
This does not happen on the same component on the official shad-ui library.
Screenshots
Before focus:
After focusing on button:
After moving to "next" focusable element:
Logs
No response
System Info
Able to reproduce on Chrome, but not Safari or Firefox.
Severity
annoyance
The text was updated successfully, but these errors were encountered: