Research
Recent Trends in Malicious Packages Targeting Discord
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
a11y-focus-trap
Advanced tools
Readme
A simple javascript module to trap focus in an HTML element and loop de navigation that is made using the tab key inside this element. This pretty useful for modal or alert element and help your navigation to be accessible by users with disabilities.
Install using NPM
npm install a11y-focus-trap
You can also clone the github repo and insert it directly in your project via the script tag.
Import the module in the desired file
var a11yFocusTrap = require('./a11y-focus-trap');
Have and HTML element where you want the focus to be trapped in such as:
<div id="modal">
<h3>Focus need to be trap in those element</h3>
<button id="close-modal">Close</button>
<form>
<div><input type="text" placeholder="First Name"/></div>
<div><input type="text" placeholder="Last Name"/></div>
<div><input type="submit" /></div>
</form>
</div>
Call the trapFocus
method which have two parameter. The first one is the element in which the focus will be trapped in and the second is the current active element to return the focus on once we exit the trap.
Example:
var containerElement = document.getElementById('modal');
a11yFocusTrap.trapFocus(containerElement, document.activeElement);
To cancel the focus trap, call the unTrapFocus
method. This will also return the focus on the current active element that you passed as the second parameter of the trapFocus
method.
Example:
a11yFocusTrap.unTrapFocus();
Thats it !
FAQs
A simple module to trap the tab navigation inside a container very useful for modal and dialog.
We found that a11y-focus-trap demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
Security News
Socket CEO Feross Aboukhadijeh joins a16z partners to discuss how modern, sophisticated supply chain attacks require AI-driven defenses and explore the challenges and solutions in leveraging AI for threat detection early in the development life cycle.
Security News
NIST's new AI Risk Management Framework aims to enhance the security and reliability of generative AI systems and address the unique challenges of malicious AI exploits.