From 2c99bcb58513dbb98db570f1feeeb330aa150837 Mon Sep 17 00:00:00 2001 From: Vincent Scavinner Date: Mon, 22 Jul 2024 18:02:37 +0200 Subject: [PATCH 1/2] fix: hbs render format in component tests --- .../components/amount-input/component-test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test-app/tests/integration/components/amount-input/component-test.ts b/test-app/tests/integration/components/amount-input/component-test.ts index 9a8485d1..72a27457 100644 --- a/test-app/tests/integration/components/amount-input/component-test.ts +++ b/test-app/tests/integration/components/amount-input/component-test.ts @@ -210,11 +210,11 @@ module('Integration | Component | amount-input', function (hooks) { module('and the value is not a valid amount', function () { test('calls update with an empty string value', async function (assert) { await render(hbs` - - `); + + `); await simulateUserPasteValue('input', 'foo'); From 2acb692a0e0bafb9f3c27035f9ac48b12ba17a46 Mon Sep 17 00:00:00 2001 From: Vincent Scavinner Date: Mon, 22 Jul 2024 18:03:06 +0200 Subject: [PATCH 2/2] fix: prevent default pasting event --- ember-amount-input/src/components/amount-input.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ember-amount-input/src/components/amount-input.ts b/ember-amount-input/src/components/amount-input.ts index b31499f0..187bc327 100644 --- a/ember-amount-input/src/components/amount-input.ts +++ b/ember-amount-input/src/components/amount-input.ts @@ -157,14 +157,17 @@ export default class AmountInput extends Component { @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