Giter VIP home page Giter VIP logo

pdanpdan / vue-keyboard-trap Goto Github PK

View Code? Open in Web Editor NEW
39.0 5.0 2.0 2.96 MB

Vue2 and Vue3 directive for keyboard navigation / TAB trapping - roving movement and trapping inside container

Home Page: https://pdanpdan.github.io/vue-keyboard-trap/

License: MIT License

JavaScript 48.81% Shell 0.37% HTML 5.68% Vue 32.61% Sass 7.89% CSS 4.64%
directive keyboard roving trap vue2 navigation vue3 vue a11y accessibility

vue-keyboard-trap's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vue-keyboard-trap's Issues

[BUG]: Dynamic directive fails to trap keyboard at first

Describe the bug
I tried to use dynamic directive, but it works partially. First round of tabbing escapes the trap. When I go back inside (e.g. using [SHIFT] + [TAB]), the trap works.

<dialog v-kbd-trap='visible'>
  <!-- content -->
</dialog>

Example on CodeSandbox

To Reproduce
Steps to reproduce the behavior:

  1. Use v-kbd-trap="enabled" on a rendered element
  2. Open a dialog (should change enabled to true)
  3. Click [TAB] few times
    • This will focus elements outside of the dialog
  4. Click [SHIFT] + [TAB] to get back into the dialog
  5. Click [TAB] few times again
    • This will keep focus inside the dialog

Expected behavior
The directive should keep focus inside all the time

Recording
Peek 2023-09-26 13-38

Environment:

  • OS: Ubuntu 20.04
  • Browser: Chrome, Edge, Firefox (latest versions)

Workaround
Additional <div> with v-if... so actually it means you cannot use "dynamic" mode at all.

<dialog>
  <div v-if='visible' v-kbd-trap>
    <!-- content -->
  <div>
</dialog>

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.