Closed yathomasi closed 2 years ago
This is a known behavior of "focus locking" as selected text belongs to the body
, which is not in the focus.
It is controlled via persistentFocus
property (https://github.com/theKashey/react-focus-lock/blob/master/interfaces.d.ts#L41 ) and expected to be disabled by default.
Checked random example with pure FocusOn (Chrome and Safari) and I can select any text.
Needed to set the child div with tabIndex= {0}
or set focusLock: false
. I would be very interested to know the reason behind this if you have an explanation 🙏 .
Ok. So here is the problem - if Modal
is not focusable (does not have tabindex
) - then the focus might bubble to the other parent, which might be focusable.
This is why selection might bubble up to body and focus lock will know how to handle it.
Take this example - https://codesandbox.io/s/good-react-example-modal-dialog-forked-k4imc?file=/src/App.js and:
document.activeElement
tabIndex
and repeat<div tabindex={-1}>
{modal}
</div>
With the addition of
react-focus-on
, we got this strange behavior of not being able to select any text inside theFocusOn
component.user-select
.pointer-events
is set toauto
but that shouldn't stop text-selectionI couldn't figure out what caused the issue. What could be the reason?