tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit bf831dda4234b9f9c65afdc05d1f6aba4461e8a4
parent f2d7c661cfb088abb0d2a98c988361e07c52cb88
Author: Kelly Cochrane <kcochrane@mozilla.com>
Date:   Tue,  7 Oct 2025 12:34:41 +0000

Bug 1983125 - Make delay for the sidebar's expand on hover feature a customizable pref r=jsudiaman

Differential Revision: https://phabricator.services.mozilla.com/D267677

Diffstat:
Mbrowser/app/profile/firefox.js | 1+
Mbrowser/components/sidebar/browser-sidebar.js | 38++++++++++++++++++++++++++++----------
2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js @@ -2171,6 +2171,7 @@ pref("sidebar.revamp.round-content-area", false); pref("sidebar.animation.enabled", true); pref("sidebar.animation.duration-ms", 200); pref("sidebar.animation.expand-on-hover.duration-ms", 400); +pref("sidebar.animation.expand-on-hover.delay-duration-ms", 200); // This pref is used to store user customized tools in the sidebar launcher and shouldn't be changed. // See https://firefox-source-docs.mozilla.org/browser/components/sidebar/docs/index.html for ways diff --git a/browser/components/sidebar/browser-sidebar.js b/browser/components/sidebar/browser-sidebar.js @@ -21,7 +21,6 @@ const toolsNameMap = { viewBookmarksSidebar: "bookmarks", viewCPMSidebar: "passwords", }; -const EXPAND_ON_HOVER_DEBOUNCE_RATE_MS = 200; const EXPAND_ON_HOVER_DEBOUNCE_TIMEOUT_MS = 1000; const LAUNCHER_SPLITTER_WIDTH = 4; @@ -1414,13 +1413,7 @@ var SidebarController = { async _removeHoverStateBlocker() { if (this._hoverBlockerCount == 1) { - // Manually check mouse position - let isHovered; - MousePosTracker._callListener({ - onMouseEnter: () => (isHovered = true), - onMouseLeave: () => (isHovered = false), - getMouseTargetRect: () => this.getMouseTargetRect(), - }); + let isHovered = this._checkIsHoveredOverLauncher(); // Collapse sidebar if needed if (this._state.launcherExpanded && !isHovered) { @@ -2107,6 +2100,20 @@ var SidebarController = { }, /** + * Use MousePosTracker to manually check for hover state over launcher + */ + _checkIsHoveredOverLauncher() { + // Manually check mouse position + let isHovered; + MousePosTracker._callListener({ + onMouseEnter: () => (isHovered = true), + onMouseLeave: () => (isHovered = false), + getMouseTargetRect: () => this.getMouseTargetRect(), + }); + return isHovered; + }, + + /** * Record to Glean when any of the sidebar icons are clicked. * * @param {string} commandID - Command ID of the icon. @@ -2232,9 +2239,14 @@ var SidebarController = { this._mouseEnterDeferred = Promise.withResolvers(); this.mouseEnterTask = new DeferredTask( () => { - this.debouncedMouseEnter(); + let isHovered = this._checkIsHoveredOverLauncher(); + + // Only expand sidebar if mouse is still hovering over sidebar launcher + if (isHovered) { + this.debouncedMouseEnter(); + } }, - EXPAND_ON_HOVER_DEBOUNCE_RATE_MS, + this._animationExpandOnHoverDelayDurationMs, EXPAND_ON_HOVER_DEBOUNCE_TIMEOUT_MS ); this.mouseEnterTask?.arm(); @@ -2426,6 +2438,12 @@ XPCOMUtils.defineLazyPreferenceGetter( ); XPCOMUtils.defineLazyPreferenceGetter( SidebarController, + "_animationExpandOnHoverDelayDurationMs", + "sidebar.animation.expand-on-hover.delay-duration-ms", + 200 +); +XPCOMUtils.defineLazyPreferenceGetter( + SidebarController, "sidebarRevampEnabled", "sidebar.revamp", false,