-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add ability to customize navigation announcer #966
Conversation
This introduces a new `$app/a11y`, which for now only exports `setNavigationAnnouncer`. Closes #879
@@ -169,6 +169,9 @@ function generate_app(manifest_data, base) { | |||
let navigated = false; | |||
let title = null; | |||
|
|||
$: navigationAnnouncer = stores.navigationAnnouncer; | |||
$: navigationAnnouncement = $navigationAnnouncer.length > 0 ? $navigationAnnouncer[$navigationAnnouncer.length - 1](title) : ('Navigated to ' + title); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be try {} catch {}
ed?
Is this the best API for something like this? It feels a little weird to me. Could we instead have another file (similar to |
I chose to not put it in one place because when you want different announcements for different routes and you'd need to model that in one place, it could get awkward quickly, also colocation would be lost. Another thing is that internationalization is probably easier to add if you have it within your |
Hm, okay. What about having it be a new |
Making this an export from Totally get your concerns about not rushing this. One half of this PR for me is to get the discussion rolling, the other half was to get to know the SvelteKit codebase a little 😄 |
packages/kit/test/apps/basics/src/routes/accessibility/c.svelte
Outdated
Show resolved
Hide resolved
Out of the options raised I think the current implementation or making it an |
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
closing in favour of #1305, per yesterday's discussion |
This introduces a new
$app/a11y
, which for now only exportssetNavigationAnnouncer
, which makes i possible to customize the navigation announcer, which should also solve the internationalization-part of it. The default stays untouched - which could be changed. It also could be enhanced such that one could turn it off if one returnsnull
- up for discussion.Closes #879
Before submitting the PR, please make sure you do the following
Tests
pnpm test
and lint the project withpnpm lint
Changesets
pnpx changeset
and following the prompts