From 0d4e5497e242ddec11e960290d2579ee90eabde4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=A3=AE=E6=96=8C?= Date: Wed, 26 Jul 2023 17:25:33 +0800 Subject: [PATCH] [Bug] fix widget undo bug (#15741) * fix widget undo bug * next tick snapshot --- editor/inspector/components/widget.js | 28 ++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/editor/inspector/components/widget.js b/editor/inspector/components/widget.js index 2b6fafc719..8c7b0b371a 100644 --- a/editor/inspector/components/widget.js +++ b/editor/inspector/components/widget.js @@ -565,6 +565,12 @@ exports.methods = { this.$refs.summitProp.dispatch('change-dump'); }, + snapshot() { + // next tick snapshot + setTimeout(() => { + this.$refs.summitProp.dispatch('confirm-dump'); + }); + }, getUnit(type) { const data = this.dump.value; @@ -661,6 +667,7 @@ exports.methods = { const { dump } = update(this.dump, true); this.$refs.summitProp.dump = dump; this.$refs.summitProp.dispatch('change-dump'); + this.snapshot(); }, select(event) { @@ -892,7 +899,7 @@ exports.methods = { this.dimensionVertical = this.getDimensionVertical(); } - this.$refs.summitProp.dispatch('confirm-dump'); + this.snapshot(); }, toggleLock(direction) { @@ -931,6 +938,7 @@ exports.methods = { } this.$refs.summitProp.dispatch('change-dump'); + this.snapshot(); }, isLock(direction) { const lockValue = this.dump.value._lockFlags.value; @@ -1046,7 +1054,9 @@ const template = /* html*/` @@ -1065,6 +1075,7 @@ const template = /* html*/` :disabled="!dump.value.isAlignHorizontalCenter.value" :value="dump.value.editorHorizontalCenter.value" @change="change('editorHorizontalCenter', $event.target.value)" + @confirm="snapshot()" @unit-click="changeUnit('editorHorizontalCenter')"> @@ -1078,7 +1089,9 @@ const template = /* html*/` @@ -1121,7 +1134,9 @@ const template = /* html*/` @@ -1139,6 +1154,7 @@ const template = /* html*/` @@ -1153,7 +1169,9 @@ const template = /* html*/`