theKashey / react-focus-lock

It is a trap! A lock for a Focus. 🔓
MIT License
1.27k stars 67 forks source link

Now With tabIndex=-1 does not skip focusing, is there a way to blacklist a focusable HTML element in FocusLock ? #187

Closed abhimanyu-singh-uber closed 2 years ago

abhimanyu-singh-uber commented 2 years ago

This is my use case:

<FocusLock>
<button tabIndex="-1">Dont want this focused ever</button>
<button>Can be focused focused ever</button>
</FocusLock>

Before react-focus-lock@2.4.0, this used to work just fine with tabIndex=-1, but now >=2.4.0, even setting tabIndex=-1, makes the elements focusable, Is there a way to blacklist an element from focusing now?

theKashey commented 2 years ago

Sounds like a regression as there was no intended change around tabindex functionality.

theKashey commented 2 years ago

Cannot reproduce https://codesandbox.io/s/react-focus-lock-tabindex-1-example-48opn?file=/index.js

abhimanyu-singh-uber commented 2 years ago

Hi Sorry, I completely forgot about this.

For now, My use case is fixed with setting autoFocus=false, and I can't think of a proper use case where we might need to blacklist a div from focus. Hence, closing it for now.