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(whiteboard): Prevent Parent Id Crash when Erasing Grouped Shapes #16423
fix(whiteboard): Prevent Parent Id Crash when Erasing Grouped Shapes #16423
Conversation
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
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.
I am getting errors both when using the eraser tool and by pressing "delete" to erase selected grouped shapes
Screencast.from.2023-01-10.14-42-25.webm
Screencast.from.2023-01-10.14-41-37.webm
Screencast.from.2023-01-10.14-39-16.webm
if (shapes[eid]?.type !== 'group') { | ||
orderedDeletedShapes.unshift(eid); | ||
} else { | ||
orderedDeletedShapes.push(eid) |
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.
I think it has to be the reverse here, first delete the group shape, and then the children
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.
deleting the group shape first leads to the "shape has a parent that does not exist" error
} | ||
}); | ||
|
||
removeShapes(orderedDeletedShapes, whiteboardId); |
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.
Also, I noticed we are sending empty removeAnnotations messages to akka when the list is empty here (probably it was already like this before).
There is no side-effect, but it's better to add a check if it's not empty
What does this PR do?
This PR orders the id's of the shapes to be deleted, making sure the shapes of type group are removed last.
Motivation
Prevents the following parent id crash when deleting grouped shapes with the eraser.