Skip to content

Commit 6a6aca3

Browse files
jasonvargaclaudewaldemar-p
authored
[6.x] Fix LivePreview listener leak and simplify Grid row updates (#14583)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Waldemar Pankratz <waldemar.pankratz@voll.digital>
1 parent 19a5b8e commit 6a6aca3

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

resources/js/components/fieldtypes/grid/Row.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,11 @@ export default {
9898
9999
methods: {
100100
updated(handle, value) {
101-
let row = JSON.parse(JSON.stringify(this.values));
102-
row[handle] = value;
103-
this.$emit('updated', this.index, row);
101+
this.$emit('updated', this.index, { ...this.values, [handle]: value });
104102
},
105103
106104
metaUpdated(handle, value) {
107-
let meta = clone(this.meta);
108-
meta[handle] = value;
109-
this.$emit('meta-updated', meta);
105+
this.$emit('meta-updated', { ...this.meta, [handle]: value });
110106
},
111107
112108
fieldPath(handle) {

resources/js/components/ui/LivePreview/LivePreview.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,14 @@ const keybinding = ref(
295295
}),
296296
);
297297
298-
onUnmounted(() => keybinding.value.destroy());
298+
const refreshHandler = () => { if (props.enabled) update(); };
299+
const refreshEvent = `live-preview.${name.value}.refresh`;
299300
300-
Statamic.$events.$on(`live-preview.${name.value}.refresh`, () => {
301-
if (props.enabled) update();
301+
Statamic.$events.$on(refreshEvent, refreshHandler);
302+
303+
onUnmounted(() => {
304+
keybinding.value.destroy();
305+
Statamic.$events.$off(refreshEvent, refreshHandler);
302306
});
303307
</script>
304308

0 commit comments

Comments
 (0)