tor-browser

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

commit 33bba5cfe4a89dda0ee07fa9fbac578353713fd3
parent 5bc42c38a75f82d3dbaf6843ef81b2c7f2b85a56
Author: Reem H <42309026+reemhamz@users.noreply.github.com>
Date:   Mon,  5 Jan 2026 06:44:42 +0000

Bug 2007490 - Close customization panel on page refresh when using hash URLs. r=home-newtab-reviewers,nina-py

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

Diffstat:
Mbrowser/extensions/newtab/content-src/components/Base/Base.jsx | 16+++++++++++++++-
Mbrowser/extensions/newtab/data/content/activity-stream.bundle.js | 13++++++++++++-
2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/browser/extensions/newtab/content-src/components/Base/Base.jsx b/browser/extensions/newtab/content-src/components/Base/Base.jsx @@ -246,10 +246,24 @@ export class BaseContent extends React.PureComponent { if (hash === "#customize-topics") { this.toggleSectionsMgmtPanel(); } + } else if (this.props.App.customizeMenuVisible) { + this.closeCustomizationMenu(); } }; - this._onHashChange(); + // Using the Performance API to detect page reload vs fresh navigation. + // Only open customize menu on fresh navigation, not on page refresh. + // See: https://developer.mozilla.org/en-US/docs/Web/API/Performance/getEntriesByType + // See: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry/entryType#navigation + // See: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming/type + const isReload = + globalThis.performance?.getEntriesByType("navigation")[0]?.type === + "reload"; + + if (!isReload) { + this._onHashChange(); + } + globalThis.addEventListener("hashchange", this._onHashChange); } diff --git a/browser/extensions/newtab/data/content/activity-stream.bundle.js b/browser/extensions/newtab/data/content/activity-stream.bundle.js @@ -15740,9 +15740,20 @@ class BaseContent extends (external_React_default()).PureComponent { if (hash === "#customize-topics") { this.toggleSectionsMgmtPanel(); } + } else if (this.props.App.customizeMenuVisible) { + this.closeCustomizationMenu(); } }; - this._onHashChange(); + + // Using the Performance API to detect page reload vs fresh navigation. + // Only open customize menu on fresh navigation, not on page refresh. + // See: https://developer.mozilla.org/en-US/docs/Web/API/Performance/getEntriesByType + // See: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry/entryType#navigation + // See: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming/type + const isReload = globalThis.performance?.getEntriesByType("navigation")[0]?.type === "reload"; + if (!isReload) { + this._onHashChange(); + } globalThis.addEventListener("hashchange", this._onHashChange); } componentDidUpdate(prevProps) {