Socket
Socket
Sign inDemoInstall

ember-autofocus-modifier

Package Overview
Dependencies
537
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ember-autofocus-modifier

Wraps a modifier to autofocus an element in the DOM.


Version published
Weekly downloads
25K
decreased by-1.43%
Maintainers
2
Created
Weekly downloads
 

Changelog

Source

5.1.0 (2023-03-23)

  • Add release-it to package (abfb7ef)
  • Release 5.1.0 (3bcc7fa)
  • Update package version to help release-it know which version to release (724ab58)
  • Add description in package.json file (4556a9a)
  • Include changelog in released package (272db10)
  • Add changelog that was lose during the migration to v2 (b669c0e)
  • 📝 Backport README from v2 addon migration (dd6f6b2)
  • Update test-app/config/ember-cli-update.json (925c1a3)
  • Remove ember-data from the test-app (it's unused and causing issues), also get off beta versions (b09462f)
  • Remove ember-classic from C.I. (7fe7d21)
  • Downgrade ember-qunit to v5 to retain ember 3.24 support (4ba6ece)
  • Setup volta and correct yarn version (601c8ce)
  • For embroider-optimized, add packageRules, since the test-app makes up its own components (4c92fd6)
  • Add ember-3.24 back to ember-try matrix (8f76c5b)
  • Run npx ember-addon-migrator (475efae)

Readme

Source

ember-autofocus-modifier-illustration

ember-autofocus-modifier

Your ember component has just been rendered. Have you ever wanted to focus an element in the DOM right after that? Like focusing this lonely input on your page? Or like focusing a full-screen modal's close button?

This package wraps a modifier to autofocus an element in the DOM. It works for inputs and for other elements.

As an alternative to installing this package, you might want to consider using this snippet.

Usage

By default, it will search for the first non-disabled input in the dom node that it has been attached to.

You can specify a custom selector to target other element as the first positional parameter.

If no child is found, then it will try to focus the element itself.

Examples

To set the autofocus to an ember component:
<MyComponent {{autofocus}} />
To set the autofocus to a native html element:
<input {{autofocus}} />
To set the autofocus to the first focusable input of an html container:

Here, #input-2 will be focused as input-1 is disabled:

<form {{autofocus}}>
  <input id="input-1" disabled="disabled" />
  <input id="input-2" />
  <button type="submit" />
</form>
To set the autofocus to something else than an input in a node's children:

Here, the autofocus will be applied to the button

<form {{autofocus "button"}}>
  <input />
  <input />
  <button type="submit" />
</form>
If the autofocus is applied multiple times, the latest element will be auto-focused:

Here, the autofocus will be applied to the button

<form>
  <input {{autofocus}} />
  <input {{autofocus}} />
  <button {{autofocus}} type="submit" />
</form>

Installation

yarn add -D ember-autofocus-modifier

or

npm install --save-dev ember-autofocus-modifier

Compatibility

  • Ember.js v3.28 or above
  • Ember CLI v3.28 or above
  • Node.js v16 or above

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

Keywords

FAQs

Last updated on 23 Mar 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc