Skip to content

Commit

Permalink
Load provisional drafts for entries nested in cke field when previewing
Browse files Browse the repository at this point in the history
  • Loading branch information
i-just authored and brandonkelly committed Feb 18, 2025
1 parent 7a366ba commit 99414cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/data/FieldData.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,20 @@ public function loadEntries(): void
$entryIds = $entryChunks->map(fn(Entry $chunk) => $chunk->entryId)->all();

if (!empty($entryIds)) {
$entries = EntryElement::find()
$query = EntryElement::find()
->id($entryIds)
->siteId($this->siteId)
->status(null)
->drafts(null)
->revisions(null)
->trashed(null)
->indexBy('id')
->all();
->indexBy('id');

if (Craft::$app->getRequest()->getIsPreview()) {
$query->withProvisionalDrafts();
}

$entries = $query->all();
} else {
$entries = [];
}
Expand Down
5 changes: 5 additions & 0 deletions src/web/assets/ckeditor/src/entries/entriesui.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ export default class CraftEntriesUI extends Plugin {
params: {
siteId: siteId,
},
onLoad: () => {
slideout.elementEditor.on('update', () => {
Craft.Preview.refresh();
});
},
onBeforeSubmit: async () => {
// If the nested element is primarily owned by the canonical entry being edited,
// then ensure we're working with a draft and save the nested entry changes to the draft
Expand Down

0 comments on commit 99414cc

Please sign in to comment.