Skip to content

Commit

Permalink
fix(webseal): better paste
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Bouquillon committed Jul 26, 2023
1 parent 69c9085 commit 9202580
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/webseal/src/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ export const Form = ({ onSubmit, initialFormData }) => {
}, [watch]);

const onValuePaste = (e) => {
const value = e.clipboardData.getData("Text");
e.preventDefault();
setValue("value", toEnv(value));
const pastedValue = e.clipboardData.getData("Text");
const isSelected =
e.target.selectionStart === 0 && e.target.selectionEnd === value.length;
if (pastedValue && (value.trim() === "" || isSelected)) {
e.preventDefault();
setValue("value", toEnv(pastedValue));
}
};

return (
Expand Down

0 comments on commit 9202580

Please sign in to comment.