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

Pasting to empty React instance results in error (excluding keyboard paste) #691

Open
aduth opened this issue Jun 2, 2022 · 0 comments
Open

Comments

@aduth
Copy link

aduth commented Jun 2, 2022

Steps to reproduce:

  1. Copy some text to your clipboard, like this: 1234
  2. Go to React JS demo page: https://jsfiddle.net/nosir/gLLsrxxf/
  3. Right click the first field in the preview, and click "Paste"

Expected: No errors in developer tools console.
Actual: There's a console error:

cleave-react.min.js:8 Uncaught TypeError: Cannot read properties of undefined (reading 'slice')

In some initial debugging, it seems to be due to the fact that onChange calls Util.getPostDelimiter with owner.lastInputValue, but lastInputValue is undefined when first initialized. No errors are logged if you paste with keyboard (CmdV), but only because the combination of key presses incurs preceding keydown events which would ensure lastInputValue is assigned by the time onChange is invoked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant