Skip to content

Inconsistent crossbrowser onBeforeInput paste event behavior #21742

Open
@johtso

Description

@johtso

React version: 17.0.2

In Chrome, pasting triggers onPaste and onBeforeInput, with the nativeEvents ClipboardEvent and TextEvent respectively.

In Firefox, pasting only triggers onPaste with nativeEvent paste.

If I'm not mistaken, this seems to be the code responsible for not triggering onBeforeInput on native paste events:

case 'paste':
// If a paste event occurs after a keypress, throw out the input
// chars. Paste events should not lead to BeforeInput events.
return null;

React version: 17.0.2 and 18.0.0

17.0.2
https://codesandbox.io/s/condescending-cerf-e1qt9?file=/src/App.js
18.0.0
https://codesandbox.io/s/sparkling-sun-fylti?file=/src/App.js

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions