Code Monkey home page Code Monkey logo

focus-trap's Introduction

focus-trap's People

Contributors

andreasbm avatar

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

focus-trap's Issues

aria-disabled should be focusable

Currently, focus-trap doesn't allow for focusing of elements with aria-disabled=true. For accessibility reasons, aria-disabled=true is often used instead of disabled to allow for the element to be tabbed to. Can we at least get an opt-in option to not consider elements with aria-disabled=true when determining whether it can be focused?

Thanks!

|| ($elem.hasAttribute("aria-disabled") && $elem.getAttribute("aria-disabled") !== "false");

Slot traversal issue

I think I've found an issue where for some cases, a focusable element does not properly get included in the set of trapped elements.

The component is written using Lit Element and the render method looks like this:

render() {
    if (!this.open) return html``;
    return html`
      ${this._fabricStylesheet}
      <focus-trap>
        <div @click="${this._dismiss}" class="${c.backdrop}">
          <div
            class="${c.modal}"
            tabindex="-1"
            role="dialog"
            aria-modal="true"
            aria-labelledby="fabric_modal_id"
            @click="${this._containerClick}"
            @keydown="${this._containerKeyDown}"
          >
            <div class="${c.title}">
              ${this.left ? html`
              <button type="button" aria-label="Tilbake" class="${this._leftButtonClasses}" @click="${this._dismiss}">
                ${leftButtonSvg}
              </button>` : ''}
              <div id="fabric_modal_id" class="${this._titleClasses}">
                <p class="${c.titleText}">
                  <slot name="title"></slot>
                </p>
              </div>
              ${this.right ? html`
              <button type="button" aria-label="Lukk" class="${this._rightButtonClasses}" @click="${this._dismiss}">
                ${rightButtonSvg}
              </button>` : ''}
            </div>
            <div class="${c.content}">
              <slot></slot>
            </div>
            <div class="${c.footer}">
              <slot name="footer"></slot>
            </div>
          </div>
        </div>
      </focus-trap>
    `;

Some examples

This works...

<f-modal right>
  This is the main content
  <button>one</button>
  <button>two</button>
  <button>three</button>
</f-modal>
clip1.mov

And this works...

<f-modal right>
  <h1 slot="title">
    <button>header button</button>
  </h1>
  This is the main content
  <button>one</button>
  <button>two</button>
  <button>three</button>
</f-modal>
clip2.mov

But this does not work...
The right hand x button is not included in the trap. Except.. that if you use shift + tab you can get to it. If you tab, it is skipped.

<f-modal right>
  <h1 slot="title">header</h1>
  This is the main content
  <button>one</button>
  <button>two</button>
  <button>three</button>
</f-modal>
clip3.mov

Is this a bug or am I doing something wrong here?

Thanks!

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.