fix(core): prevent cached show page data in create forms#7475
Open
Woutuuur wants to merge 2 commits into
Open
Conversation
with cached show-page data when action is 'create'"
🦋 Changeset detectedLatest commit: fc27249 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
same-resource create forms
06a468e to
fc27249
Compare
|
This looks like a solid fix and the root cause is clearly addressed. Avoiding passing the The regression test is especially valuable here since this kind of issue can easily resurface with future changes. One small thing to clarify:
Otherwise, the approach is clean and well-scoped. Good to go from my side. |
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.
PR Checklist
Please check if your PR fulfills the following requirements:
Bugs / Features
What is the current behavior?
When opening a create modal (
useModalFormwithaction: "create") on a show page for the same resource, the form'sdefaultValuesare overwritten by cached data from the show page'suseOnequery. This happens becauseuseFormpasses the URL-derivedidtouseOneeven for create actions, causing a query key collision with the cached entry. TheuseModalFormvisibility reset effect then callsreset()with the cached show-page data, replacing the user-provideddefaultValues.What is the new behavior?
useForm):idis no longer passed touseOnewhen the action is"create", preventing the cache key collision at the source.useModalForm): The visibility reset effect is guarded against"create"actions, so it never callsreset()with query data for create forms.Create modal forms now correctly retain their
defaultValuesregardless of cached data from the same resource.