Skip to content

Add regression coverage for formatOnBlur submit field state#1090

Open
erikras-richard-agent wants to merge 1 commit intomainfrom
agent/oss-138-gh981-1778137615
Open

Add regression coverage for formatOnBlur submit field state#1090
erikras-richard-agent wants to merge 1 commit intomainfrom
agent/oss-138-gh981-1778137615

Conversation

@erikras-richard-agent
Copy link
Copy Markdown
Contributor

@erikras-richard-agent erikras-richard-agent commented May 7, 2026

Summary

  • Add regression coverage for GH#981 around formatOnBlur submit handling when a field's state is no longer available.
  • Confirms submit no longer throws if beforeSubmit runs after the field state has been removed.

Verification

  • NODE_ENV=test npx jest src/Field.test.js -t "should not throw when formatOnBlur beforeSubmit" --runInBand
  • yarn test

Fixes #981

Summary by CodeRabbit

  • Tests
    • Added test coverage for edge cases in form submission handling to ensure robust behavior when field state is unavailable during cleanup.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 102c6516-c715-4193-ab80-3571d9c66c8c

📥 Commits

Reviewing files that changed from the base of the PR and between 4271873 and b5c431d.

📒 Files selected for processing (1)
  • src/Field.test.js

📝 Walkthrough

Walkthrough

A regression test is added to validate that formatOnBlur does not throw an exception when the form's field state becomes unavailable during submit-triggered cleanup. The test temporarily stubs formApi.getFieldState to return undefined, triggers a submit action, and verifies no error is raised.

Changes

Regression Test for Field State Availability

Layer / File(s) Summary
Regression Test Case
src/Field.test.js
New test validates formatOnBlur handles missing field state gracefully when formApi.getFieldState returns undefined during submit. Test stubs the method, triggers submit, asserts no exception, and verifies onSubmit was called once.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • final-form/react-final-form#1085: Introduces changes to useField/formatOnBlur that adjust blur/change handlers, directly related to the defensive behavior being tested in this regression test.

Suggested reviewers

  • erikras

Poem

🐰 A test hops forth with care so keen,
When fields vanish in submit's scene,
No errors thrown, no values lost,
Just gentle grace through cleanup's frost,
formatOnBlur stands the test unseen! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding regression test coverage for the formatOnBlur submit field state issue.
Linked Issues check ✅ Passed The test directly addresses issue #981 by verifying that formatOnBlur does not throw when field state becomes unavailable during submit cleanup.
Out of Scope Changes check ✅ Passed All changes are focused on adding a regression test for issue #981; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/oss-138-gh981-1778137615

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

beforeSubmit 'value' is undefined error after removing neighboring text input

1 participant