Skip to content

Fix number leading zeros and required validation in custom components#4

Merged
preshin merged 2 commits intomainfrom
fix/number-leading-zeros-and-required-validation
Apr 2, 2026
Merged

Fix number leading zeros and required validation in custom components#4
preshin merged 2 commits intomainfrom
fix/number-leading-zeros-and-required-validation

Conversation

@preshin
Copy link
Copy Markdown
Owner

@preshin preshin commented Apr 2, 2026

  • Patch NumberComponent.createNumberMask to set allowLeadingZeroes: true, preventing the mask from stripping leading zeros when a second digit is typed (e.g. typing "07" no longer becomes "7").

  • Fix createFormComponent updateValue: accept and forward flags, return the actual changed boolean instead of always true, and only call updateOnChange when the value has changed (matches formio base class behaviour).

  • Add _onReactChange helper that passes { modified: true } when the React component's onChange fires, so custom components correctly mark themselves as non-pristine and show inline validation errors in real time.

  • Add resolve.dedupe for react/react-dom in vite.config dev mode to prevent duplicate React instance errors when running the example dev server.

  • Add BugFixDemo to example/main.jsx to verify both fixes interactively.

Made-with: Cursor

- Patch NumberComponent.createNumberMask to set allowLeadingZeroes: true,
  preventing the mask from stripping leading zeros when a second digit is
  typed (e.g. typing "07" no longer becomes "7").

- Fix createFormComponent updateValue: accept and forward flags, return the
  actual changed boolean instead of always true, and only call updateOnChange
  when the value has changed (matches formio base class behaviour).

- Add _onReactChange helper that passes { modified: true } when the React
  component's onChange fires, so custom components correctly mark themselves
  as non-pristine and show inline validation errors in real time.

- Add resolve.dedupe for react/react-dom in vite.config dev mode to prevent
  duplicate React instance errors when running the example dev server.

- Add BugFixDemo to example/main.jsx to verify both fixes interactively.

Made-with: Cursor
@preshin preshin self-assigned this Apr 2, 2026
Runs npm ci + npm run build on every PR targeting main and on pushes
to main. Also verifies that the expected dist output files are present
after the build so a silent vite misconfiguration cannot slip through.

Made-with: Cursor
@preshin preshin merged commit b11aaa7 into main Apr 2, 2026
1 check passed
@preshin preshin deleted the fix/number-leading-zeros-and-required-validation branch April 2, 2026 15:45
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