featherlight icon indicating copy to clipboard operation
featherlight copied to clipboard

support tabindex within the modal

Open ryancwalsh opened this issue 8 years ago • 9 comments

What kind of issue is this? (put 'x' between the square brackets)

  • [ ] Question. This issue tracker is not the place for questions. If you want to ask how to do something, or to understand why something isn't working the way you expect it to, use http://stackoverflow.com/questions/ask . Provide working code, starting from http://jsfiddle.net/JNsu6/15/. We monitor the tag featherlight.js.

  • [x] Bug report. If you’ve found a bug, you must provide a minimal example in a CodePen, starting from http://jsfiddle.net/JNsu6/15/ .

  • [ ] Feature Request. Make sure there's no good way to do what you want first; consider asking on http://stackoverflow.com/questions/ask first.

Please see http://stackoverflow.com/a/42235457/470749

My form (look at the demo fiddle here, and I've also pasted some code below) seems not to support tabindex inside the Featherlight modal.

I think it's because of this part of Featherlight here.

How can I display a form within a modal and still let a user press the TAB key to bounce to the next field?

ryancwalsh avatar Feb 15 '17 00:02 ryancwalsh

Just to confirm that it is a bug. I plan to address it at my earliest convenience. Saddly, it's not trivial to fix correctly.

marcandre avatar Feb 20 '17 19:02 marcandre

I'm also experiencing this bug. Makes it very unpleasant to use forms inside featherlight modals.

aprea avatar Apr 24 '17 04:04 aprea

Love featherlight except for this. I'm using @ryancwalsh's fix on SO but I could see it breaking upon update. I am guessing it's not trivial to fix because you still want to disable tabbing outside the modal? For me I'd be fine with a parameter that turns off this behavior completely which is essentially what ryan's fix does. Thanks ryan btw!

eyevandy avatar Apr 26 '17 19:04 eyevandy

+1 for @ryancwalsh fix on SO (same problem, same fix).

lingtalfi avatar Jun 08 '17 11:06 lingtalfi

@lingtalfi and @eyevandy if you like https://stackoverflow.com/q/42234790/470749 and my answer on that page, they could use an upvote 😉 Glad it helped. I love SO.

ryancwalsh avatar Jun 08 '17 21:06 ryancwalsh

done :), and thanks for the help by the way, parsing the whole source code takes some time, and your answer just saves us that much time.

lingtalfi avatar Jun 08 '17 21:06 lingtalfi

I encountered this same issue while working on a project this morning. My solution was to just loop through each input field and set the tab index on the afterOpen callback.

$.featherlight( $( '.element' ), {
  afterOpen: function() {
    
    var count = 1;
    
    $( '.element > .featherlight-content' ).find( 'input, select, textarea, button.continue' ).each( function() {
      $( this ).attr( 'tabindex', count++ );
    } );
  
  },
} );

Seems to work well, for my needs anyway, while this bug is patched. Hopefully it might help others.

EvanHerman avatar Mar 16 '18 12:03 EvanHerman

Any update on this?

dkjensen avatar Apr 25 '20 17:04 dkjensen

I dropped an answer on the SO post that updates the .not selector to leave items in the modal alone. Its a different take then updating the tabindex after it is overridden. It's definitely not polished but it might help someone down the line.

wolffereast avatar Aug 24 '20 20:08 wolffereast