Bugfix/224 undo and nested entries #228
Merged
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
Scenario 1:
When you just created a nested entry in the CKEditor field, delete it, wait for autosave to complete, and use undo to bring it back.
In the above scenario, the nested entry has already been soft deleted, so when you undo it, you get a card with an “Invalid entry ID” message. If you then refresh the page, the card shows correctly because the soft-deleted entry has been restored. I don’t see a way to detect if the undo command has been fired before editing downcast completes, so this is the only way I can think of to fix the issue.
Scenario 2:
Add a nested entry to the CKEditor field, save the parent entry, delete the nested element, wait for autosave to complete, use undo to bring it back and save the parent entry again - once the page reloads, the nested entry card is rendered as deleted (it’ll show as deleted with the fix for scenario 1 in place; without it it’ll show as invalid entry id).
It was happening because the ownership info was deleted the moment the nested entry was deleted, and it was not brought back on undo. Ensuring the ownership data is stored when downcasting the
craftEntryModel
ensures all following queries work as expected and the nested entry isn’t soft-deleted.Related issues
#224