Cas ce-0052 · Scénario scenario-paste-event-handling

preventDefault on paste event does not prevent default paste behavior

OS: Windows 11 Appareil: Desktop or Laptop Any Navigateur: Chrome 120.0 Clavier: US Brouillon
pasteeventspreventDefaultchrome

Cette page n'a pas encore été traduite

Le contenu original en anglais est actuellement affiché. Nous apprécierions votre contribution à la traduction.

Phenomenon

In Chrome on Windows, calling preventDefault() on the paste event does not always prevent the default paste behavior. Content may still be pasted despite the prevention.

Reproduction example

  1. Create a contenteditable div.
  2. Add a paste event listener that calls event.preventDefault().
  3. Copy some text.
  4. Paste into the contenteditable.
  5. Observe whether the paste is prevented.

Observed behavior

  • In Chrome on Windows, preventDefault() on paste may not work.
  • Content may still be pasted.
  • The default behavior is not consistently prevented.

Expected behavior

  • preventDefault() on paste should prevent the default paste behavior.
  • No content should be pasted when prevented.
  • The behavior should be consistent and reliable.

Playground for this case

Use the reported environment as a reference and record what happens in your environment while interacting with the editable area.

Reported environment
OS: Windows 11
Device: Desktop or Laptop Any
Browser: Chrome 120.0
Keyboard: US
Your environment

Use this editable area to reproduce the described case.

Event log
Use this log together with the case description when filing or updating an issue.
0 events
Interact with the editable area to see events here.