From a72e879dd7ba3c45e2c261f51810b44607aa188d Mon Sep 17 00:00:00 2001 From: liangx <46127018+15100399015@users.noreply.github.com> Date: Tue, 24 Oct 2023 22:13:38 +0800 Subject: [PATCH 1/2] bugfix: issues/182 --- .../Properties/page/PagePagePropertiesPanel.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/solidui-web/src/pages/Designer/Properties/page/PagePagePropertiesPanel.tsx b/solidui-web/src/pages/Designer/Properties/page/PagePagePropertiesPanel.tsx index 3149ef2..4040db1 100644 --- a/solidui-web/src/pages/Designer/Properties/page/PagePagePropertiesPanel.tsx +++ b/solidui-web/src/pages/Designer/Properties/page/PagePagePropertiesPanel.tsx @@ -15,7 +15,7 @@ * limitations under the License. */ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { isNil } from "lodash-es"; import { PropertyElement, InputNumber } from "@/components"; import { mm, eventbus } from "@/utils"; @@ -23,11 +23,21 @@ import { mm, eventbus } from "@/utils"; export default function PagePagePropertiesPanel() { const page = mm.getCurrentPage(); - const [size] = useState<{ width: number; height: number }>({ + const [size, setSize] = useState<{ width: number; height: number }>({ width: page?.size.width || 1024, height: page?.size.height || 768, }); + useEffect(() => { + eventbus.on("onSelectPage", () => { + const page = mm.getCurrentPage(); + setSize({ + width: page?.size.width || 1024, + height: page?.size.height || 768, + }); + }); + }, []); + return ( <> @@ -45,6 +55,7 @@ export default function PagePagePropertiesPanel() { width: value, height: page.size.height, }; + setSize(page.size) eventbus.emit("onPageWidthChange", { value, }); @@ -67,6 +78,7 @@ export default function PagePagePropertiesPanel() { width: page.size.width, height: value, }; + setSize(page.size) eventbus.emit("onPageHeightChange", { value, }); From 36e47092bf0a5d934670da10797f63238cd3001d Mon Sep 17 00:00:00 2001 From: liangx <46127018+15100399015@users.noreply.github.com> Date: Tue, 24 Oct 2023 22:25:44 +0800 Subject: [PATCH 2/2] bugfix: issues/182 --- .../Properties/page/PagePagePropertiesPanel.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/solidui-web/src/pages/Designer/Properties/page/PagePagePropertiesPanel.tsx b/solidui-web/src/pages/Designer/Properties/page/PagePagePropertiesPanel.tsx index 4040db1..ed5f81e 100644 --- a/solidui-web/src/pages/Designer/Properties/page/PagePagePropertiesPanel.tsx +++ b/solidui-web/src/pages/Designer/Properties/page/PagePagePropertiesPanel.tsx @@ -29,13 +29,17 @@ export default function PagePagePropertiesPanel() { }); useEffect(() => { - eventbus.on("onSelectPage", () => { + const onSelectPage = () => { const page = mm.getCurrentPage(); setSize({ width: page?.size.width || 1024, height: page?.size.height || 768, }); - }); + }; + eventbus.on("onSelectPage", onSelectPage); + return () => { + eventbus.off("onSelectPage", onSelectPage); + }; }, []); return ( @@ -55,7 +59,7 @@ export default function PagePagePropertiesPanel() { width: value, height: page.size.height, }; - setSize(page.size) + setSize(page.size); eventbus.emit("onPageWidthChange", { value, }); @@ -78,7 +82,7 @@ export default function PagePagePropertiesPanel() { width: page.size.width, height: value, }; - setSize(page.size) + setSize(page.size); eventbus.emit("onPageHeightChange", { value, });