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/form): prohibit focus and unset on root input #6706

Merged
merged 2 commits into from
May 22, 2024
Merged

Conversation

skogsmaskin
Copy link
Member

@skogsmaskin skogsmaskin commented May 16, 2024

Description

NOTE: this PR builds on top of #6705 and this should be merged first.

This will prohibit that a input for a object modal inside the PT-input can call onPathFocus or unset() on itself.

Calling onPathFocus([]) will focus the editor element and close the editing modal.

Also if the input calls unset() on itself (like the Reference Input) it will cause the modal to abruptly dissapear, and we might miss out on any cleanup and other expected functions in the editor when this happens.

This change will make sure that any input for the PT-content inside the editor will not be allowed to do this.
onPathFocus([]) will be a no-op, and unset([]) will instead reset the object (keeping _key and _type) allowing the editor to deal normally with the object (will be removed when the modal is closed and object it empty).

Also added test for this.

What to review

That it seems like a good idea and the proper solution.

Testing

Should be covered by automatic tests. See an example in the provided story if you want to test manually.

Notes for release

  • Fixed bugs that related to when the PT-input is using a Reference input directly as the annotation type (not wrapped in a object type).

Copy link

vercel bot commented May 16, 2024

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

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2024 10:57am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2024 10:57am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2024 10:57am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview May 22, 2024 10:57am

@skogsmaskin skogsmaskin marked this pull request as ready for review May 16, 2024 19:01
@skogsmaskin skogsmaskin requested a review from a team May 16, 2024 19:01
@skogsmaskin skogsmaskin requested a review from a team as a code owner May 16, 2024 19:01
@skogsmaskin skogsmaskin requested review from jtpetty and removed request for a team May 16, 2024 19:01
Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented May 16, 2024

Component Testing Report Updated May 22, 2024 10:58 AM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 36s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 7s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 27s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 32s 11 7 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 15s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 9s 3 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 36s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 17s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 4s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 7s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 21s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 15s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 30s 12 0 0

This will disallow the object edit input to set onFocus([]) and unset([]) on itself,
as this will disrupt the pattern the PT-input uses for editing it's embedded objects.
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