react icon indicating copy to clipboard operation
react copied to clipboard

Bug: [Firefox] Removing an element with contentEditable="true" within an iframe and an RTL selection causes an exception

Open lorenzo-pomili opened this issue 2 years ago • 3 comments

selecting from right to left inside an element that is inside an iframe and the iframe is removed it cause an exception

React version:

Steps To Reproduce

component:

const ElementWithTheException = () => {
  const [ show, setShow ] = useState(true);
  useEffect(() => {
    setTimeout(() => {
      setShow(false);
    }, 5000);
  });

  return <div>
    {show ? <iframe src="about:blank" srcDoc='<html><body contentEditable="true">lorem ipsum</body></html>'></iframe> : <p>abc</p>}
  </div>;
};
  1. in Firefox
  2. select from right to left lorem ipsum (or part of it)
  3. wait 5 seconds
  4. look at the console

Link to code example:

  1. open https://codesandbox.io/s/inspiring-volhard-lctcsx in Firefox
  2. select from right to left lorem ispum or part of it
  3. wait

The current behavior

it raise an exception

The expected behavior

it should not raise an exception

NOTE: I did some debug:

  • The exception is thrown by this selection.extend in setOffsets.
  • Which is called by setSelection because in this case, the body does not have selectionStart
  • Which is called by restoreSelection and this is because isInDocument refers to the document of the element so, in this case, the document itself is contained in the element that is removed

lorenzo-pomili avatar Jun 20 '23 09:06 lorenzo-pomili

image [Safari] also

nawfelsekrafi avatar Feb 05 '24 10:02 nawfelsekrafi

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

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

The bug seems still present to me, and considering @nawfelsekrafi comment I'm not the only one affected by it, there is something that I can do to help you with it?

lorenzo-pomili avatar May 06 '24 07:05 lorenzo-pomili

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

github-actions[bot] avatar Aug 04 '24 08:08 github-actions[bot]

bump

lorenzo-pomili avatar Aug 05 '24 06:08 lorenzo-pomili