text selection in modal broken since google chrome 80
See original GitHub issueSince version update 80 of chrome (chrome edge as well) the text selection is broken in a modal dialog when a focusable element is present. FYI it still works well in latest ie11 and Firefox though.
//"react": "16.12.0"
//"react-bootstrap": "0.33.0"
//"react-focus-lock": "2.2.1"
import React from 'react'
import { Modal } from 'react-bootstrap'
import FocusLock from 'react-focus-lock'
const ModalWrapper = props => {
return (
<Modal show={true}>
<FocusLock persistentFocus={false}>
<div>
<div>FOO</div>
<button>close</button>
</div>
</FocusLock>
</Modal>
)
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Selecting text using Javascript in bootstrap modal dialog is not ...
I am working on a task where text in a div has been to selected on button click event. The select is not...
Read more >Cannot interact with dropdown within Bootstrap modal #600
I created a jsfiddle to repro the issue below, but its slightly different than the behavior I was seeing in my own project....
Read more >Chrome 80 arrives with mixed content autoupgraded to ...
Google Chrome 80 brings autoupgrading mixed content to HTTPS, SameSite cookie changes, quieter permission UI for notifications, and more ...
Read more >Text in fields disappeared/became invisible when page item in ...
Text fields on our modal pages disappear when they have focus. We applied the suggested CSS change and this fixed issue for several...
Read more >Use a text cursor to navigate & select text - Google Chrome Help
On your computer, open Chrome Chrome . · Select More Organize and then Settings. · At the bottom left, click Accessibility. · Turn...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

So, this is not focus-lock related bug, and I am not sure why it works in other browsers/browser versions.
Modalhas atabindex=-1, which makes it focusable, but not tabbable (which is absolutely correct). Once you are trying to “select a text” - you do click on aModal, and thus focusing it.Modalis outside of theFocusLock“Selection” works only if focus is on the body, ie nothing else is “selectable” between “you” and the body.
How to fix
Put
FocusLockoutside of theModal, or provide arefto aModalinshardsprop (I’ve tried, look likeModaldo not supportref)Thanks for the conclusion. I will try this out.