Skip to content

Commit

Permalink
fix: prevent default pasting event
Browse files Browse the repository at this point in the history
  • Loading branch information
vscav committed Jul 22, 2024
1 parent 2c99bcb commit 2acb692
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ember-amount-input/src/components/amount-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,17 @@ export default class AmountInput extends Component<AmountInputSignature> {

@action
onPaste(event: ClipboardEvent): boolean {
event.preventDefault();

const pastedValue = event.clipboardData?.getData('text');
const parsedValue = parseFloat(pastedValue?.replace(/\s/g, '') ?? '');

if (!isNaN(parsedValue)) {
this.args.update(parsedValue.toFixed(this.numberOfDecimal));
return true;
}

return true;
return false;
}

@action
Expand Down

0 comments on commit 2acb692

Please sign in to comment.