Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blur-accessibly

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blur-accessibly

Use `element.blur()` without losing the `tab` position

  • 0.9.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

blur-accessibly

Use element.blur() without losing the tab position.

Firefox (v71) / Safari (v13): The native Element.blur() resets the tab focus to the start of the document; This module places it back next to the blurred field/element.

Chrome (v79): element.blur() works correctly there.

Install

You can just download the standalone bundle (it might take a minute to download)

Or use npm:

npm install blur-accessibly
// This module is only offered as a ES Module
import blurAccessibly from 'blur-accessibly';

Usage

// Instead of calling `element.blur()`
blurAccessibly(element);

For example if you want to blur a field by pressing esc:

document.querySelector('textarea').addEventListener('keydown', event => {
  if (event.key === 'Escape') {
    blurAccessibly(event.target);
  }
});

API

blurAccessibly(element);

element

Type: HTMLElement

The element to call .blur() on. The tabindex will be preserved around it (textarea and input, except in Safari) or after it elsewhere.

  • indent-textarea - Add editor-like tab-to-indent functionality to <textarea>, in a few bytes.
  • insert-text-textarea - Insert text in a textarea (supports Firefox and Undo). Used by this module.
  • fit-textarea - Automatically expand a <textarea> to fit its content, in a few bytes.
  • delegate-it - DOM event delegation, in <1KB. Can be used to attach one blur-accessibly to many elements.

Keywords

FAQs

Package last updated on 14 Dec 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc