Skip to content

Commit

Permalink
reloadOnBroadcastSave
Browse files Browse the repository at this point in the history
#14814
[ci skip]
  • Loading branch information
brandonkelly committed May 21, 2024
1 parent 152cb0a commit 9bf546e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- Added `craft\db\setRestoreFormat()`.
- Added `craft\events\InvalidateElementcachesEvent::$element`.
- Added `craft\fields\BaseRelationField::existsQueryCondition()`.
- Added the `reloadOnBroadcastSave` setting to `Craft.ElementEditor`. ([#14814](https://github.com/craftcms/cms/issues/14814))

### System
- Improved the performance of `exists()` element queries.
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions src/web/assets/cp/src/js/ElementEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,19 @@ Craft.ElementEditor = Garnish.Base.extend(
ev.data.id === this.settings.canonicalId &&
!this.settings.draftId)
) {
Craft.setUrl(
Craft.getUrl(document.location.href, {
scrollY: window.scrollY,
})
);
window.location.reload();
// Reload unless reloadOnBroadcastSave is disabled (unless the
// draftId is different, in which case we really need to reload)
if (
this.settings.reloadOnBroadcastSave ||
ev.data.draftId !== this.settings.draftId
) {
Craft.setUrl(
Craft.getUrl(document.location.href, {
scrollY: window.scrollY,
})
);
window.location.reload();
}
} else if (
ev.data.event === 'deleteDraft' &&
ev.data.canonicalId === this.settings.canonicalId &&
Expand Down Expand Up @@ -2235,6 +2242,7 @@ Craft.ElementEditor = Garnish.Base.extend(
visibleLayoutElements: {},
updatedTimestamp: null,
canonicalUpdatedTimestamp: null,
reloadOnBroadcastSave: true,
},
}
);

0 comments on commit 9bf546e

Please sign in to comment.