From f0fe930aae2aa936d85abfca58cbab3cd3cbb968 Mon Sep 17 00:00:00 2001 From: tamaina Date: Mon, 26 Dec 2022 12:55:10 +0900 Subject: fix(client): prevent infinite resize loop (#9232) * clientWidth? * spacer? * size directive? * size directive * use const --- packages/client/src/components/global/MkSpacer.vue | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'packages/client/src/components/global') diff --git a/packages/client/src/components/global/MkSpacer.vue b/packages/client/src/components/global/MkSpacer.vue index c7d53f2ee7..b3a42d77e7 100644 --- a/packages/client/src/components/global/MkSpacer.vue +++ b/packages/client/src/components/global/MkSpacer.vue @@ -24,6 +24,8 @@ let ro: ResizeObserver; let root = $ref(); let content = $ref(); let margin = $ref(0); +const widthHistory = [null, null] as [number | null, number | null]; +const heightHistory = [null, null] as [number | null, number | null]; const shouldSpacerMin = inject('shouldSpacerMin', false); const adjust = (rect: { width: number; height: number; }) => { @@ -47,9 +49,26 @@ onMounted(() => { height: entries[0].borderBoxSize[0].blockSize, }); */ + + const width = root!.offsetWidth; + const height = root!.offsetHeight; + + //#region Prevent infinite resizing + // https://github.com/misskey-dev/misskey/issues/9076 + const pastWidth = widthHistory.pop(); + widthHistory.unshift(width); + const pastHeight = heightHistory.pop(); + heightHistory.unshift(height); + + + if (pastWidth === width && pastHeight === height) { + return; + } + //#endregion + adjust({ - width: root!.offsetWidth, - height: root!.offsetHeight, + width, + height, }); }); ro.observe(root!); -- cgit v1.2.3-freya