Skip To Content button doesn't work properly #3098
Unanswered
AnishDe12020
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Everything you're doing seems correct. I think this might be a bug in SvelteKit. I was implementing this feature on the SvelteKit doc site and ran into the same issue: sveltejs/sites#245. I was able to work around it by setting rel=external on the link, which is an attribute used by SvelteKit. But this attribute shouldn't be necessary outside of SvelteKit. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Update: Opened as an issue in #3105
In an effort to make tab navigation better on my site, I was implementing a skip to content button which would skip the navbar and directly go to the content. I have implemented it as it is normally implemented but I am running into a small problem. Normally, focussing on the skip to content button and then pressing enter gets you to the content, and pressing the tab key after that makes you cycle through the content. In my implementation, I am brought to the skip to content button twice before I can cycle through the site's content.
Details on the code
I have added a button to the layout of my website, that is in `__layout.svelte`. Here is the code:I have added some styles in
app.css
for the same:At last, I have given the content an
id
ofcontent
inindex.svelte
so that it can be scrolled down to whenever the skip to content button is engaged:Note: I was following this article on css-tricks: https://css-tricks.com/how-to-create-a-skip-to-content-link/
For more context, here is a screen recording -
2021-12-23.22-50-58.mp4
Also, I have tried this on another SvelteKit project and had faced the same issue.
I have also hosted it as a preview deployment - https://portfolio-nlaow838l-anishde12020.vercel.app/
The code for this specific feature - https://github.com/AnishDe12020/portfolio/tree/skip-to-content-button
I am not opening an issue because it can also be an issue on my end and not necessarily with SvelteKit. Any help would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions