
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
a11y-focus-trap
Advanced tools
A simple module to trap the tab navigation inside a container very useful for modal and dialog.
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.
The npm package a11y-focus-trap receives a total of 4 weekly downloads. As such, a11y-focus-trap popularity was classified as not popular.
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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.