Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): make sure to re-emit current edit state when re-subscribing to document validation #4954

Merged
merged 1 commit into from
Oct 3, 2023

Conversation

bjoerge
Copy link
Member

@bjoerge bjoerge commented Sep 27, 2023

Description

This fixes an issue that currently happens when editing a document that has a reference to an unpublished document, switching to another document and then switching back. Sometimes this could lead to the validation error for unpublished document reference being ignored.

Steps to reproduce:

  1. Go to https://test-studio.sanity.build/test/content
  2. Navigate to Standard Inputs > Reference Test > REPRO SDX-736 #1" and observe that the reference field has the correct validation error
  3. Switch to REPRO SDX-736 #2
  4. Switch back to REPRO SDX-736 #1" and notice that the validation error has disappeared.

What to review

Go to the branch deployment (https://test-studio-git-sdx-736.sanity.build/test/content) and make sure the above steps does not cause the validation error to disappear

I also took the opportunity to fixe a couple of deprecation warnings while at it.

Notes for release

  • Fixes an issue that could sometimes make reference validation errors disappear when switching between documents

@vercel
Copy link

vercel bot commented Sep 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview Sep 29, 2023 0:13am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 29, 2023 0:13am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Sep 29, 2023 0:13am

@@ -105,7 +106,7 @@ export const validation = memoize(
// so only pass on documents if _other_ attributes changes
return shallowEquals(omit(prev, '_rev', '_updatedAt'), omit(next, '_rev', '_updatedAt'))
}),
share(),
shareLatestWithRefCount(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the line that fixes the issue. Since we were using share, re-subscribing to this observable didn't publish the current edit state of the document, leaving the validation in a pending state

@github-actions
Copy link
Contributor

No changes to documentation

@github-actions
Copy link
Contributor

github-actions bot commented Sep 27, 2023

Component Testing Report Updated Sep 29, 2023 12:16 PM (UTC)

File Status Duration Passed Skipped Failed
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 12s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 10s 3 0 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 11s 6 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 14s 9 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 51s 18 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 7s 3 0 0

Copy link
Contributor

@binoy14 binoy14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test looks good to me but it would be good to have someone else's eyes on it as well since I am not very familiar with this

@bjoerge bjoerge requested a review from skogsmaskin October 3, 2023 13:28
@bjoerge bjoerge added this pull request to the merge queue Oct 3, 2023
Merged via the queue into next with commit 17300c8 Oct 3, 2023
14 checks passed
@bjoerge bjoerge deleted the sdx-736 branch October 3, 2023 14:04
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.

3 participants