Skip to content

v0.5.1

Compare
Choose a tag to compare
@renatodeleao renatodeleao released this 07 Oct 17:52
· 128 commits to master since this release

Fixes focus-trap initialFocus option handling of autofocus elements. Here's the default focus order:

1. focusRef` binding 
2. elements with `[autofocus]` attribute  — (`document.querySelector('[autofocus]'))
3. first focusable element
4. use focus-trap fallback (dialogRef)

The problem was that we weren't checking if 2 was a valid candidate for the autofocus attribute — input, select, button and textarea to be precise — and I faced a bug where a vue input component wrapper didn't have inheritAttrs: false, so a magic <div autofocus> was trying to be erroneously focused, not focusing the actual input.

Note that if you want to focus an invalid element you can still do

<div tabindex="0" v-bind="focusRef.attrs">
If you're that kind of person, don't forget the tabindex!
</div>