question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

text selection in modal broken since google chrome 80

See original GitHub issue

Since 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:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
theKasheycommented, Feb 20, 2020

So, this is not focus-lock related bug, and I am not sure why it works in other browsers/browser versions.

  • The Modal has a tabindex=-1, which makes it focusable, but not tabbable (which is absolutely correct). Once you are trying to “select a text” - you do click on a Modal, and thus focusing it.
  • The Modal is outside of the FocusLock
  • And the focus returned back.

“Selection” works only if focus is on the body, ie nothing else is “selectable” between “you” and the body.

How to fix

Put FocusLock outside of the Modal, or provide a ref to a Modal in shards prop (I’ve tried, look like Modal do not support ref)

0reactions
DonBrascommented, Feb 20, 2020

Thanks for the conclusion. I will try this out.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found