Repository navigation
fix: don't inherit parent Form props in a nested Form - #10746
Merged
Merged
Conversation
snowystinger
approved these changes
Oct 9, 2026
snowystinger
left a comment
Member
There was a problem hiding this comment.
Thanks for the quick fix!
yihuiliao
approved these changes
Oct 11, 2026
yihuiliao
left a comment
Member
There was a problem hiding this comment.
lgtm, can you sign the CLA? you'll need to close and re-open the PR to run the check
Member
|
CLA instructions are here https://github.com/adobe/react-spectrum/blob/main/CONTRIBUTING.md#contributor-license-agreement |
Contributor
Author
|
Thanks @yihuiliao and @snowystinger for the reviews and guidance! I signed the CLA and reopened the PR to rerun the checks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #10740
A RAC
Formboth provides and consumesFormContextviauseContextProps, so aFormrendered inside anotherFormin the React tree (e.g. an independent form in aModal) merged in the outer form's props: chainedonSubmit, duplicatedid/className, and inheritedvalidationErrors.Intent: a nested
Formshould be independent, while aFormContextprovided by the user (not by aForm) should keep working as it does today.Implementation: following the suggestion in the issue,
Formnow adds a private symbol to theFormContextvalue it provides. When aFormsees that marker on the incoming context, it skips merging it (passingslot: nulltouseContextProps, the existing "don't use context" escape hatch). Fields are unaffected: they only readvalidationBehaviorfromFormContext, and still get it from their nearestForm.✅ Pull Request Checklist:
📝 Test Instructions:
yarn jest packages/react-aria-components/test/Form.test.jsshould not inherit props from a parent Form: renders aFormportaled inside anotherFormand checks the inner form has no inheritedid/className, doesn't show the outer form's validation error, and submitting it doesn't call the outeronSubmit. Fails onmain, passes with this change.should merge props from FormContext not provided by a Form: a user-providedFormContext.Providerbetween two forms still applies to the inner form.Also ran the full RAC and S2 test suites and
yarn check-types.🧢 Your Project:
Personal contribution