From 1e624ae580418b06ca8cbb5744b9497f80e68921 Mon Sep 17 00:00:00 2001 From: "mr. M" Date: Thu, 6 Feb 2025 07:37:27 +0100 Subject: [PATCH] Refactor getAndApplySidebarWidth to remove async and simplify sidebar width calculation --- src/browser/base/zen-components/ZenCompactMode.mjs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/browser/base/zen-components/ZenCompactMode.mjs b/src/browser/base/zen-components/ZenCompactMode.mjs index 66c93e4e5..221d6025e 100644 --- a/src/browser/base/zen-components/ZenCompactMode.mjs +++ b/src/browser/base/zen-components/ZenCompactMode.mjs @@ -135,10 +135,8 @@ var gZenCompactModeManager = { this.animateCompactMode(); }, - async getAndApplySidebarWidth() { - let sidebarWidth = await window.promiseDocumentFlushed(() => - window.windowUtils.getBoundsWithoutFlushing(this.sidebar).width - ); + getAndApplySidebarWidth() { + let sidebarWidth = this.sidebar.getBoundingClientRect().width; if (sidebarWidth > 1) { this.sidebar.style.setProperty('--zen-sidebar-width', `${sidebarWidth}px`); } @@ -160,8 +158,8 @@ var gZenCompactModeManager = { this.sidebar.style.removeProperty('margin-right'); this.sidebar.style.removeProperty('margin-left'); this.sidebar.style.removeProperty('transform'); - window.requestAnimationFrame(async () => { - let sidebarWidth = await this.getAndApplySidebarWidth(); + window.requestAnimationFrame(() => { + let sidebarWidth = this.getAndApplySidebarWidth(); if (!canAnimate) { this.sidebar.removeAttribute('animate'); this._animating = false;