Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
ember-a11y-refocus
Advanced tools
accessibility addon to announce route change, reset focus, and provide a skip link
This addon does three things:
aria-live
).Options
section for available options).Single-Page Applications(SPAs) use pushState
to allow portions of the page to be updated or replaced without a whole new page being rendered. While this was a positive gain for performance on the web, it has made an entire type of web app not accessible (usable) for folks who depend on assistive technology(such as screen-readers) to use the web. With the prolific rise of JavaScript frameworks as the tool of choice for building modern web applications, screen-reader users have become increasingly left out of many experiences of the modern web that have become necessary for everyday life, such as online banking, paying bills, and ordering products and services.
Since pushState
does nothing to inform the browser--and, by extent, the screen reader--that new content is present, the screen-reader user has no way of knowing that new content exists, or that navigation to a new page was successful. Additionally, focus remains where it was, instead of being reset in a predictable fashion.
Async data can be loaded as it normally would be. Since this addon does not use aria-live
, it won't interfere with or compete with other loading states. This will only give the user with a screen reader a message that the route (URL) has changed, and place the focus where they expect it to be (reset to the top left of the page).
Since this will run before other content, focus can be programmatically moved by the developer to go somewhere else. The message should still read out, and is findable by users with screen readers.
ember install ember-a11y-refocus
<NavigationNarrator/>
into your application.hbs file, preferably inside of a <header>
element.id="main"
to the primary content element in your application (hopefully a <main>
element).Example:
<header>
<NavigationNarrator/>
<!-- other header content-->
</header>
<main id="main">
<!--main content-->
</main>
This addon provides support for custom definitions of which route changes should trigger refocusing behavior.
To use this functionality, pass routeChangeValidator
when you invoke the component, and add your custom action in the appropriate controller (likely the application controller).
So when you add the component to your application.hbs file:
<NavigationNarrator @routeChangeValidator={{this.myCustomValidator}} />
This is what the controller could look like:
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
myCustomValidator(transition) {
// Custom logic goes here...
}
}
The validator function:
true
if refocusing should occur, otherwise false
If you wish to extend the default behavior (rather than completely replacing it), you can import the default validator like so:
import Controller from '@ember/controller';
import { defaultValidator } from 'ember-a11y-refocus';
export default class ApplicationController extends Controller {
myCustomValidator(transition) {
if (transition.from.name === 'special') {
return false;
} else {
return defaultValidator(transition);
}
}
}
All of these are optional and have default values.
skipLink
- pass {{false}}
if you do not want to implement a bypass block/skip link.skipTo
- pass a specific element ID that should receive focus on skip. Defaults to #main
.skipText
- customize the text passed in the skip link. Defaults to Skip to main content
.navigationText
- customize the text passed as the navigation message. Defaults to The page navigation is complete. You may now navigate the page content as you wish
.excludeAllQueryParams
- pass {{true}}
if you want to exclude all query params from the route change check/focus management. Really shouldn't do this, but you might be upgrading an older app and need this for a little bit, or you are using QPs in a specific way and would like to otherwise benefit from the accessibility options in this addon. If you only need to exclude some QPs, use the custom validator function instead.With FastBoot, you'll want to guard the <NavigationNarrator />
from rendering. Like so:
{{#unless this.fastboot.isFastBoot}}
<NavigationNarrator />
{{/unless}}
Where this.fastboot
is the fastboot service injected in the application controller.
Contributions are welcome.
This project is licensed under the MIT License.
FAQs
accessibility addon to announce route change, reset focus, and provide a skip link
The npm package ember-a11y-refocus receives a total of 1,040 weekly downloads. As such, ember-a11y-refocus popularity was classified as popular.
We found that ember-a11y-refocus demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.