-
Notifications
You must be signed in to change notification settings - Fork 418
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(pte): preserve block key when pressing enter at start of block #6521
Merged
Conversation
This file contains 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
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
No changes to documentation |
Component Testing Report Updated May 2, 2024 10:38 AM (UTC)
|
pedrobonamin
commented
Apr 30, 2024
packages/@sanity/portable-text-editor/src/editor/plugins/__tests__/withHotKeys.test.tsx
Outdated
Show resolved
Hide resolved
pedrobonamin
commented
May 2, 2024
packages/@sanity/portable-text-editor/e2e-tests/__tests__/writingTogether.collaborative.test.ts
Show resolved
Hide resolved
skogsmaskin
approved these changes
May 2, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid work @pedrobonamin!
Thank you for this.
This was referenced May 31, 2024
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.
Description
fixes edx-1056.
Changes:
withInsertBreak
which handles the case of pressing enter at the start of a block.createEmptyBlock
function to the editor utils, allowing ease of reuse.Issue:
When moving a block by placing the cursor at the beginning of a block and pressing “Enter” – a new
_key
is currently generated for that block. This is problematic because comments are linked to specific blocks through the_key
. If a new_key
is generated when moving the block in this way, all comments associated with that block will disappear. This occurs because the_key
value in the comment document no longer references any block content by its_key
.This PR updates the behaviour when pressing enter key in the PTE editor, if the cursor is at the start of the block, instead of doing a
split_node
operation it will do ainsert_node
operation. This will preserve the key of the current block.Challenge: focus handling is not automatically updated by Slate and it keeps the cursor in the new inserted block instead of the block the user was. This is fixed by this change , forcing the focus path to the next block, which is the actual block, because a new block was inserted in the previous position https://github.com/sanity-io/sanity/pull/6521/files#diff-35c7a342daeb53013561d14759571db71e13c8782293a91e14f254608dbdb439R29-R32
It can be tested here https://test-studio-git-edx-1056.sanity.build/test/structure/input-standard;portable-text;pt_allTheBellsAndWhistles;e93f598b-8ec4-4bed-87aa-ab855210ed0e
What to review
Testing
Notes for release