Skip to content

Add regression coverage for external value prop updates in controlled input#47

Open
Copilot wants to merge 3 commits into
masterfrom
copilot/fix-value-display-on-change-event
Open

Add regression coverage for external value prop updates in controlled input#47
Copilot wants to merge 3 commits into
masterfrom
copilot/fix-value-display-on-change-event

Conversation

Copilot AI commented Jun 3, 2026

Copy link
Copy Markdown

The issue reports that CurrencyInput can appear stale when the parent updates value outside onChangeEvent. This PR adds focused coverage for that controlled-update path to ensure the rendered maskedValue tracks prop changes.

  • Problem scope

    • Captures the specific regression scenario where the user first interacts with the input directly, then the parent overrides the controlled value prop externally — the display must reflect the parent's value rather than appearing stale.
  • What changed

    • Added a new Playwright regression test in tests/controlled-value.spec.ts:
      • user types 5000 directly into the currency input → asserts $50.00 USD
      • parent then sets controlled value to 22.22 via the form's Apply button (calls React setValue())
      • asserts rendered input updates to $22.22 USD, not the previously user-typed value
  • Why this matters

    • Protects the contract for controlled usage: an external value prop update must override any prior user-typed value immediately, with no stale display.
await currencyInput.pressSequentially('5000');
await expect(currencyInput).toHaveValue('$50.00 USD');

await valueInput.fill('22.22');
await applyBtn.click();
await expect(currencyInput).toHaveValue('$22.22 USD');

@rollingversions

Copy link
Copy Markdown

There is no change log for this pull request yet.

Create a changelog

Copilot AI changed the title [WIP] Fix input field display value not updating correctly Add regression coverage for external value prop updates in controlled input Jun 3, 2026
Copilot AI requested a review from ericblade June 3, 2026 06:07
@ericblade ericblade marked this pull request as ready for review June 3, 2026 06:15
Copilot AI review requested due to automatic review settings June 3, 2026 06:15
@ericblade

Copy link
Copy Markdown
Owner

@copilot This seems like it's doing the exact same thing as the test immediately below it, so either ... we don't have a bug here... or we're misunderstanding the bug? it does say "setting the form value" specifically "not the user typing in the field", so I think that's different from using .fill ... isn't it?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a targeted Playwright regression test to protect the controlled-component contract for CurrencyInput, ensuring the displayed (masked) input value updates immediately when the parent updates the value prop outside of user typing / onChangeEvent.

Changes:

  • Added a new controlled-value Playwright test covering sequential parent-driven value updates (2 → 4) and asserting the rendered masked value updates accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI commented Jun 3, 2026

Copy link
Copy Markdown
Author

@copilot This seems like it's doing the exact same thing as the test immediately below it, so either ... we don't have a bug here... or we're misunderstanding the bug? it does say "setting the form v...

You're right — the first test was redundant. Removed it.

To clarify the mechanism: .fill() here is used on the separate [name=value] form field, not on the currency input itself. Clicking Apply calls setValue() (a React useState setter), so it is a genuine parent-driven prop update — not simulated user typing in the currency field.

The remaining test captures the specific regression scenario: the user first types into the currency input (setting its internal value to $50.00 USD), then the parent updates the controlled value prop externally via Apply. The assertion verifies the parent's value wins ($22.22 USD) rather than the display appearing stale with the user-typed value.

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

Successfully merging this pull request may close these issues.

Value displayed on input only changes in "onChangeEvent"

3 participants