Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: onCut is not triggered in contenteditable for collapsed selection in Firefox #23094

Closed
bryanph opened this issue Jan 11, 2022 · 3 comments
Closed
Labels
Resolution: Stale Automatically closed due to inactivity Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@bryanph
Copy link

bryanph commented Jan 11, 2022

React version: 17.x, 18.x

Steps To Reproduce

  1. Open the react 17/18 codesandbox in firefox
  2. Click on the text and keep selection collapsed
  3. Press ctrl-x
  4. No onCut event is fired (no window.alert shows)
  5. Compare with react 16 codesandbox where it does work

Link to code example:

The current behavior

onCut is not triggered in firefox

Note this does work in chrome, or firefox with react 16

The expected behavior

onCut is triggered in firefox

@bryanph
Copy link
Author

bryanph commented Jan 21, 2022

After playing around a little more I got a working example in react 18. The trick is to assign an empty event listener to the cut event to document. It seems that for some reason firefox requires you to listen to the cut event at the document level in order for cut events to trigger elsewhere? Not sure if we can attribute this to firefox or some react handling.

See https://codesandbox.io/s/contenteditable-cut-react-18-working-drqnl?file=/src/App.tsx:179-188 for a working version

Copy link

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 github-actions bot added the Resolution: Stale Automatically closed due to inactivity label Apr 10, 2024
Copy link

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Stale Automatically closed due to inactivity Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

1 participant