From 3fe7087271b5efa82c70fe8d473fb63e91036f40 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 06:17:03 +0000 Subject: [PATCH 1/4] Initial plan From 14cdc3814ae509cd64f0f6b35ec1c7375f9f1f6a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 06:24:45 +0000 Subject: [PATCH 2/4] Fix getDerivedStateFromProps to handle simultaneous allowNegative and format prop changes Co-authored-by: ericblade <1451847+ericblade@users.noreply.github.com> --- src/index.tsx | 36 +++++++++++++++++------------------- tests/base.spec.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 202b507..2b0a62d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -189,13 +189,17 @@ class CurrencyInput extends React.Component { value = await currencyInput.inputValue(); expect(value).not.toContain('-'); }); + + test('removes negative sign when allowNegative is disabled and format changes simultaneously', async ({ page }) => { + // First enable allowNegative + const allowNegativeCheckbox = page.locator('[name=allowNegative]'); + const prefixInput = page.locator('[name=prefix]'); + const applyBtn = page.locator('[name=apply]'); + const currencyInput = page.locator('#currency-input'); + + await allowNegativeCheckbox.check(); + await applyBtn.click(); + await expect(currencyInput).toHaveValue('$0.00 USD'); + await currencyInput.focus(); + await currencyInput.selectText(); + + // Input a negative number + await currencyInput.pressSequentially('50'); + await currencyInput.press('Minus'); + + let value = await currencyInput.inputValue(); + expect(value).toContain('-'); + + // Now disable allowNegative AND change prefix at the same time + await allowNegativeCheckbox.uncheck(); + await prefixInput.fill('€'); + await applyBtn.click(); + + // Value should now be positive AND have the new prefix + value = await currencyInput.inputValue(); + expect(value).not.toContain('-'); + expect(value).toContain('€'); + expect(value).toContain('50'); + }); }); test.describe('allowEmpty', () => { From d06dc55d8b55391de87cfbc49c95952491fa1fd8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 06:26:25 +0000 Subject: [PATCH 3/4] Add clarifying comment for valueToFormat initialization Co-authored-by: ericblade <1451847+ericblade@users.noreply.github.com> --- src/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 2b0a62d..9cf1374 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -209,7 +209,8 @@ class CurrencyInput extends React.Component Date: Sun, 14 Dec 2025 06:28:11 +0000 Subject: [PATCH 4/4] Fix whitespace for consistency with codebase style Co-authored-by: ericblade <1451847+ericblade@users.noreply.github.com> --- src/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 9cf1374..1cd9df6 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -212,7 +212,7 @@ class CurrencyInput extends React.Component