Skip to content

Address bugs in numeric autofill - #1398

Open
martha wants to merge 4 commits into
mainfrom
mke/8917-numeric-autofill-bugs
Open

Address bugs in numeric autofill#1398
martha wants to merge 4 commits into
mainfrom
mke/8917-numeric-autofill-bugs

Conversation

@martha

@martha martha commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Description

Summary of changes:

  • In NumberInput, when triggering the onChange handler, pass the sourceInfo to indicate whether this event was triggered by a user or a system-generated change like autofill.
    • Why this is necessary for NumberInput specifically: NumberInput uses the react NumericFormat component internally, which calls onValueChange anytime the value changes.
    • That was causing the RHF state to mark the form field as "dirty" even when it had been autofilled. Whereas, normal autofill explicitly set showDirty: false:

useEffect(() => {
// Don't autofill this field if it's been edited (i.e. is dirty)
// for example, we automatically set the radio choice for Income Source to true if any of the income fields are non-zero
if (isDirty && userEditable) return;
if (!autofillValue) return;
// Don't autofill if the value is already set
if (isEqual(autofillValue.value, getValues(linkId))) return;
setValue(linkId, autofillValue.value, { shouldDirty: false });
}, [autofillValue, linkId, getValues, setValue, isDirty, userEditable]);

  • Expand the existing autofill behavior to clear an autofilled value when the dependent item changes. This was previously in place only for readonly autofilled items. This PR proposes to expand that behavior to user-editable autofilled items, which seems more intuitive. Please let me know if you think there's a side effect I may be missing.

How to test: See QA instructions on ticket

Type of change

Bug fix

Checklist before requesting review

  • I have performed a self-review of my code
  • I have run the code that is being changed under ideal conditions, and it doesn't fail
  • I have used Axe DevTools to scan for accessibility issues (or not applicable)
  • My code includes comments and/or descriptive variable names to help other engineers understand the intent (or not applicable)
  • My code follows the style guidelines of this project (eslint)
  • I have updated the documentation (or not applicable)
  • If it's not obvious how to test this change, I have provided testing instructions in this PR or the related issue

@martha
martha marked this pull request as ready for review March 5, 2026 14:36
@martha
martha requested a review from gigxz March 5, 2026 14:36
@martha
martha changed the base branch from release-203 to release-205 March 13, 2026 12:00
@martha
martha changed the base branch from release-205 to release-207 March 27, 2026 13:39
Base automatically changed from release-207 to stable April 23, 2026 18:22
@martha
martha changed the base branch from stable to main May 21, 2026 19:43
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.

1 participant