-
Notifications
You must be signed in to change notification settings - Fork 430
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(@sanity): remove warning for when child within PTE has no key #6565
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
No changes to documentation |
Component Testing Report Updated May 6, 2024 12:43 PM (UTC)
|
…don't have keys in pte
@@ -59,6 +60,13 @@ export function createWithSchemaTypes({ | |||
const key = span._key || keyGenerator() | |||
Transforms.setNodes(editor, {...span, _type: schemaTypes.span.name, _key: key}, {at: path}) | |||
} | |||
|
|||
// catches cases when the children are missing keys but excludes it when the normalize is running the node as the editor object | |||
if (node._key === undefined && !_.isEqual(node, editor)) { |
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.
@skogsmaskin had to add the condition since the tests showed that the editor itself was falling in this condition (since it has no _key itself)
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.
Great with tests for this, and good catch that we need to test the node for what it is.
I have some small comments on this which I'd like to change.
packages/@sanity/portable-text-editor/src/editor/plugins/createWithSchemaTypes.ts
Outdated
Show resolved
Hide resolved
packages/@sanity/portable-text-editor/src/editor/plugins/createWithSchemaTypes.ts
Outdated
Show resolved
Hide resolved
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.
Thanks @RitaDias !
Description
Working on removing some warnings from PTE when we can self fix it ourselves.
In this case we are removing the warning when a child doesn't have a _key then the PTE should automatically create one for them.
What to review
Check that it makes sense, there are automated tests.
Testing
If you choose to do it manually you can create a document via de CLI such as:
when you enter that document in the test studio you will then be able to see that
Notes for release
When child within the PTE is created with a _key, we now automatically create one for it avoiding unnecessary warning.