Giter Club home page Giter Club logo

makeup-keyboard-trap's Introduction

makeup-keyboard-trap

The source code for this package has been moved to a monorepo. This repo will be archived and then scheduled for deletion.

makeup-keyboard-trap's People

Contributors

darkwebdev avatar ianmcburnie avatar scttdavs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

makeup-keyboard-trap's Issues

Add way to reset focus elements

If the content is modified the focus elements may not be valid targets anymore. I can resubmit the trap, but that has the extra overhead of re-adding the DOM elements. It would be good if we could just tell the plugin to reselect the first and last focus elements.

Vanilla JS Implementation

When I first saw your implementation for keyboard trap using JQuery I was so excited.
I was waiting for vanilla JS implementation too long so I've implemented it myself a month ago.
Now I've found you did this vanilla JS version and I'm very pleased to see that's my version is very similar to what you've done, I still don't understand why you need outer traps, though.
Thank you very much for what you've done and for the inspiration that you gave me with your JQuery version of this plugin.

my vanilla js implementation:
https://codepen.io/Konrud/pen/RgjxOL

Instantiate trap elements lazily, instead of on require

Run the following code lazily, the first time trap is called, instead of when module is required. This should help server-side use case too.

let topTrap = util.createTrapBoundary();
let outerTrapBefore = util.createTrapBoundary();
let innerTrapBefore = util.createTrapBoundary();
let innerTrapAfter = util.createTrapBoundary();
let outerTrapAfter = util.createTrapBoundary();
let botTrap = util.createTrapBoundary();

topTrap.addEventListener('focus', setFocusToFirstFocusableElement);
outerTrapBefore.addEventListener('focus', setFocusToFirstFocusableElement);
innerTrapBefore.addEventListener('focus', setFocusToLastFocusableElement);
innerTrapAfter.addEventListener('focus', setFocusToFirstFocusableElement);
outerTrapAfter.addEventListener('focus', setFocusToLastFocusableElement);
botTrap.addEventListener('focus', setFocusToLastFocusableElement);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.