-
Notifications
You must be signed in to change notification settings - Fork 944
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
There is the media placeholder example in the: docs. Inside media-placeholder-node component, there’s a call to updateUploadHistory.
In this function, we try to find an index by iterating over editor.history.undos. If undos is empty, or if we can’t find the item with batch.operations.some, index will be -1.
Currently, the code does:
const batch = editor.history.undos[index];
for (const operation of batch.operations) { ... }
When index is -1, batch is undefined, and for (const operation of batch.operations) throws an error.
I think we should check that index is not -1 before proceeding.
Also, can someone clarify the purpose of this function?
Reproduction URL
No response
Reproduction steps
1. Try to insert image
2. Error appearsPlate version
52.0.1
Slate React version
52.0.1
Screenshots
Logs
TypeError: Cannot read properties of undefined (reading 'operations')Browsers
Chrome
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working