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

refactor(core/inputs): report focusPath on text spans ending with .text #5786

Merged
merged 3 commits into from
Feb 19, 2024

Conversation

skogsmaskin
Copy link
Member

Description

This will make the PT-input report the focusPath when the focus is on text spans ending with text so that the Presentation Tool can work out of the box without making any exceptions for the PT-input.

With this change, we have a bi-directional mapping of focus with the forms and the presentation tool.

Note that this will not change the PTE EditorSelection which will continue reporting as before, it's only the studio-specific focusPath reporting that will be affected by this change.

What to review

  • That regular form focus works as expected
  • That the Presentation Tool focus handling works as expected
  • That features like AI-Assist still works as expected.

Testing

Notes for release

  • Improved focus handling with the Presentation tool and Portable Text Inputs.

@skogsmaskin skogsmaskin requested review from a team and jtpetty and removed request for a team February 19, 2024 11:03
Copy link

vercel bot commented Feb 19, 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 Feb 19, 2024 11:16am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2024 11:16am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Feb 19, 2024 11:16am

Copy link
Contributor

No changes to documentation

// It's a bit ugly right here, but it's a rather simple way to support the Presentation tool without
// having to change the PTE's internals.
if (
focusPath.length === 3 &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Paraphrasing tommy, why is the length === 3 here? What does it means when it's 3?

Copy link
Member Author

@skogsmaskin skogsmaskin Feb 19, 2024

Choose a reason for hiding this comment

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

It means that the path is pointing directly to a block child, i.e:
[{_key: 'xxx'}, 'children', {_key: 'yyy'}] - where xxx is the block and yyy is the child.

Copy link
Contributor

github-actions bot commented Feb 19, 2024

Component Testing Report Updated Feb 19, 2024 11:19 AM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 32s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 11s 3 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 13s 4 2 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 33s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 18s 9 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 0s 18 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 13s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 19s 9 0 0

…Path on same length

This will ensure that any external focusPath is compared with the relevant length of something visible in the editor.
If there is something pointing further into an object, we don't care, because it's only relevant so far regarding setting focus in the editor.
Copy link
Member

@stipsan stipsan left a comment

Choose a reason for hiding this comment

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

Tested, seems to work really well 👍

@skogsmaskin skogsmaskin added this pull request to the merge queue Feb 19, 2024
Merged via the queue into next with commit 3941d86 Feb 19, 2024
40 checks passed
@skogsmaskin skogsmaskin deleted the edx-1075 branch February 19, 2024 17:47
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