Added a timeout before the newtab url bar can clear it's content

This commit is contained in:
mr. M
2025-02-10 22:16:50 +01:00
parent b5c889ab01
commit be2a44dab9
2 changed files with 16 additions and 3 deletions

View File

@@ -118,6 +118,7 @@ pref('zen.view.compact.animate-sidebar', true);
pref('zen.urlbar.replace-newtab', true);
pref('zen.urlbar.behavior', 'floating-on-type'); // default, floating-on-type, float
pref('zen.urlbar.wait-to-clear', 45000); // in ms (default 45s)
#ifdef XP_MACOSX
// Disable for macos in the meantime until @HarryHeres finds a solution for hight DPI screens
@@ -167,7 +168,7 @@ pref('zen.tab-unloader.excluded-urls', "example.com,example.org");
pref('zen.pinned-tab-manager.debug', false);
pref('zen.pinned-tab-manager.restore-pinned-tabs-to-pinned-url', false);
pref('zen.pinned-tab-manager.close-shortcut-behavior', 'switch');
pref('zen.pinned-tab-manager.close-shortcut-behavior', 'unload-switch');
// TODO: Check this out!
pref("browser.profiles.enabled", false);

View File

@@ -8,6 +8,7 @@ var gZenUIManager = {
document.addEventListener('popuphidden', this.onPopupHidden.bind(this));
XPCOMUtils.defineLazyPreferenceGetter(this, 'sidebarHeightThrottle', 'zen.view.sidebar-height-throttle', 500);
XPCOMUtils.defineLazyPreferenceGetter(this, 'contentElementSeparation', 'zen.theme.content-element-separation', 0);
XPCOMUtils.defineLazyPreferenceGetter(this, 'urlbarWaitToClear', 'zen.urlbar.wait-to-clear', 0);
ChromeUtils.defineLazyGetter(this, 'motion', () => {
return ChromeUtils.importESModule('chrome://browser/content/zen-vendor/motion.min.mjs', { global: 'current' });
@@ -149,11 +150,15 @@ var gZenUIManager = {
_prevUrlbarLabel: null,
_lastSearch: '',
_clearTimeout: null,
handleNewTab(werePassedURL, searchClipboard, where) {
const shouldOpenURLBar =
Services.prefs.getBoolPref('zen.urlbar.replace-newtab') && !werePassedURL && !searchClipboard && where === 'tab';
if (shouldOpenURLBar) {
if (this._clearTimeout) {
clearTimeout(this._clearTimeout);
}
this._prevUrlbarLabel = gURLBar._untrimmedValue;
gURLBar._zenHandleUrlbarClose = this.handleUrlbarClose.bind(this);
gURLBar.setAttribute('zen-newtab', true);
@@ -164,14 +169,21 @@ var gZenUIManager = {
return false;
},
clearUrlbarData() {
this._prevUrlbarLabel = null;
this._lastSearch = '';
},
handleUrlbarClose(onSwitch) {
gURLBar._zenHandleUrlbarClose = null;
gURLBar.removeAttribute('zen-newtab');
if (onSwitch) {
this._prevUrlbarLabel = null;
this._lastSearch = '';
this.clearUrlbarData();
} else {
this._lastSearch = gURLBar._untrimmedValue;
this._clearTimeout = setTimeout(() => {
this.clearUrlbarData();
}, this.urlbarWaitToClear);
}
gURLBar.setURI(this._prevUrlbarLabel, onSwitch, false, false, !onSwitch);
gURLBar.handleRevert();