The button loses focus from the button when moving to the next subpages
See original GitHub issueThe button loses focus from the button when moving to the next subpages: Example (with a description of the problem): https://github.com/lukaszpolowczyk/focus-button
Problem
- Refresh page
- Press
Tab key
on the keyboard - The button are focused
- Press
Right Arrow
on the keyboard - The button loses focus
Question: How do I keep focus without using element.focus()
or anything like that?
GIF with this:
The code looks like this:
<!-- src/routers/[slug].svelte -->
<svelte:head><title>Lost focus - Sveltekit Routers</title></svelte:head>
<script>
import { page } from '$app/stores';
</script>
<br>
page {$page.params.slug}
<!-- src/routers/$layout.svelte -->
<script>
import { page } from '$app/stores';
import { goto } from '$app/navigation';
import Keydown from "svelte-keydown";
</script>
<Keydown on:ArrowRight={() => goto(`${Number($page.params.slug)+1}`) } />
<button on:click={()=>goto(`${Number($page.params.slug)+1}`)}>goto({Number($page.params.slug)+1})</button>
or press RightArrow
<slot />
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Click on a button that is moved when an input loses focus is ...
When the input is focused and the user tries to click the button, it loses the focus which may cause the hint to...
Read more >Create and manage pages – Figma Help Center
Get in the habit of moving new components to the dedicated page. ... Click New project in the menu bar: Image showing the...
Read more >51580 (Application Passwords: Accessibility Improvements)
There is a focus loss when clicking the "Revoke" button though. The button gets removed together with the table row and focus is...
Read more >A Beginner's Guide to Notion (2022 Update) - The Sweet Setup
You can create pages in a variety of ways in Notion — you can click the + button beside your workspace in the...
Read more >PowerPoint Tips: The Magical Reset Button | Stinson Design
Move content, change fonts, add colors. ... Any change you make to the placeholder boxes can be reset. Just remember that if you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
GitHub issues are reserved for bug reports or feature requests. Please ask usage questions on StackOverflow or the Discord server.
By default a page change will not keep the element focused, that’s an accessibility best practice default. You’ll need to handle that yourself.
@dummdidumm @ahtcx I want it too. Maybe similar to
sveltekit:noscroll
andgoto(href, { replaceState, noscroll })
, e.g.sveltekit:keepfocus
andgoto(href, { replaceState, keepfocus })
?It looks like something easy to do. L245 of
router.js
would have to give in a similar condition as L254 ofrouter.js
.