react icon indicating copy to clipboard operation
react copied to clipboard

fix: firefox Uncaught DOMException: Selection.extend: No selection ra…

Open nusr opened this issue 2 years ago • 4 comments
trafficstars

…nge exists

Summary

If Selection.extend is called while another element has focus, an error is thrown. We therefore disable extend if the active element is somewhere other than the node we are selecting. This should only occur in Firefox, since it is the only browser to support multiple selections.See https://bugzilla.mozilla.org/show_bug.cgi?id=921444. Firefox will trrigger InvalidStateError: Selection.extend: No selection range exists. Safari will trigger InvalidStateError: extend() requires a Range to be added to the Selection.

How did you test this change?

The code logic refers to draft-js fix #26980

nusr avatar Jun 27 '23 03:06 nusr

Comparing: aaa4acb1280fcda398defb805db47a8623df6c0f...35c91475954121bae886bc03a93940d3592555c6

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js +0.01% 176.86 kB 176.89 kB +0.02% 55.14 kB 55.15 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +0.01% 179.01 kB 179.03 kB +0.01% 55.78 kB 55.79 kB
facebook-www/ReactDOM-prod.classic.js +0.02% 592.40 kB 592.51 kB +0.02% 104.67 kB 104.69 kB
facebook-www/ReactDOM-prod.modern.js +0.02% 575.68 kB 575.80 kB = 101.66 kB 101.67 kB
test_utils/ReactAllWarnings.js Deleted 66.50 kB 0.00 kB Deleted 16.27 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
test_utils/ReactAllWarnings.js Deleted 66.50 kB 0.00 kB Deleted 16.27 kB 0.00 kB

Generated by :no_entry_sign: dangerJS against 35c91475954121bae886bc03a93940d3592555c6

react-sizebot avatar Jun 27 '23 03:06 react-sizebot

Can you prepare a Codesandbox showing this is fixed? A build from this PR is available under https://react-builds.vercel.app/api/prs/27013/packages/react for react and https://react-builds.vercel.app/api/prs/27013/packages/react-dom for react-dom

eps1lon avatar Feb 23 '24 16:02 eps1lon

Can you prepare a Codesandbox showing this is fixed? A build from this PR is available under https://react-builds.vercel.app/api/prs/27013/packages/react for react and https://react-builds.vercel.app/api/prs/27013/packages/react-dom for react-dom

Before change

https://codesandbox.io/p/sandbox/inspiring-volhard-lctcsx?file=%2Fsrc%2FApp.js Steps To Reproduce

  1. in Firefox or Safari
  2. select from right to left lorem ipsum (or part of it)
  3. wait 5 seconds
  4. look at the console

After change

https://codesandbox.io/p/sandbox/react-firefox-jtyv2p?file=%2Fsrc%2FApp.js%3A10%2C14 I have tested it inside Safari,Firefox,Edge and Chrome. It's all ok.

nusr avatar Feb 24 '24 07:02 nusr

This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.

github-actions[bot] avatar May 24 '24 08:05 github-actions[bot]

Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!

github-actions[bot] avatar May 31 '24 08:05 github-actions[bot]