Bug 1949808 - Prevent smart tab topic output from replacing group label if user starts typing r=vazish,tabbrowser-reviewers,dao
adding additional check before populating input Differential Revision: https://phabricator.services.mozilla.com/D240223
This commit is contained in:
@@ -99,7 +99,6 @@
|
||||
this.tabContainer = document.getElementById("tabbrowser-tabs");
|
||||
this.tabGroupMenu = document.getElementById("tab-group-editor");
|
||||
this.tabbox = document.getElementById("tabbrowser-tabbox");
|
||||
this.tabGroupNameField = document.getElementById("tab-group-name");
|
||||
this.tabpanels = document.getElementById("tabbrowser-tabpanels");
|
||||
this.verticalPinnedTabsContainer = document.getElementById(
|
||||
"vertical-pinned-tabs-container"
|
||||
@@ -168,11 +167,6 @@
|
||||
"security.notification_enable_delay",
|
||||
500
|
||||
);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"_smartTabGroupsEnabled",
|
||||
"browser.tabs.groups.smart.enabled"
|
||||
);
|
||||
|
||||
if (AppConstants.MOZ_CRASHREPORTER) {
|
||||
ChromeUtils.defineESModuleGetters(this, {
|
||||
@@ -189,7 +183,6 @@
|
||||
window.addEventListener("activate", this);
|
||||
window.addEventListener("deactivate", this);
|
||||
window.addEventListener("TabGroupCreate", this);
|
||||
window.addEventListener("MlLabelCreate", this);
|
||||
|
||||
this.tabContainer.init();
|
||||
this._setupInitialBrowserAndTab();
|
||||
@@ -2962,21 +2955,6 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this._smartTabGroupsEnabled) {
|
||||
gBrowser.getGroupTitleForTabs(tabs).then(newLabel => {
|
||||
group.label = newLabel;
|
||||
if (this.tabGroupMenu.panel.state !== "closed") {
|
||||
this.tabGroupNameField.value = newLabel;
|
||||
group.dispatchEvent(
|
||||
new CustomEvent("MlLabelCreate", {
|
||||
bubbles: true,
|
||||
detail: { mlLabel: newLabel },
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
group.dispatchEvent(
|
||||
new CustomEvent("TabGroupCreate", {
|
||||
bubbles: true,
|
||||
@@ -6722,11 +6700,6 @@
|
||||
this.tabGroupMenu.openCreateModal(aEvent.target);
|
||||
}
|
||||
break;
|
||||
case "MlLabelCreate":
|
||||
if (aEvent.detail.mlLabel) {
|
||||
this.tabGroupMenu.mlLabel = aEvent.detail.mlLabel;
|
||||
}
|
||||
break;
|
||||
case "activate":
|
||||
// Intentional fallthrough
|
||||
case "deactivate":
|
||||
|
||||
@@ -588,6 +588,38 @@
|
||||
return "bottomleft topleft";
|
||||
}
|
||||
|
||||
#initMlGroupLabel() {
|
||||
if (!this.smartTabGroupsEnabled) {
|
||||
return;
|
||||
}
|
||||
gBrowser.getGroupTitleForTabs(this.activeGroup.tabs).then(newLabel => {
|
||||
this.#setMlGroupLabel(newLabel);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the label should be updated with the suggested label
|
||||
* @returns {boolean}
|
||||
*/
|
||||
#shouldUpdateLabelWithMlLabel() {
|
||||
return !this.#nameField.value && this.panel.state !== "closed";
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to set the label of the group to the suggested label
|
||||
* @param {MozTabbrowserTabGroup} group
|
||||
* @param {string} newLabel
|
||||
* @returns
|
||||
*/
|
||||
#setMlGroupLabel(newLabel) {
|
||||
if (!this.#shouldUpdateLabelWithMlLabel()) {
|
||||
return;
|
||||
}
|
||||
this.#activeGroup.label = newLabel;
|
||||
this.#nameField.value = newLabel;
|
||||
this.#suggestedMlLabel = newLabel;
|
||||
}
|
||||
|
||||
openCreateModal(group) {
|
||||
this.activeGroup = group;
|
||||
this.createMode = true;
|
||||
@@ -598,10 +630,11 @@
|
||||
this.#panel.openPopup(group.firstChild, {
|
||||
position: this.#panelPosition,
|
||||
});
|
||||
this.#initMlGroupLabel();
|
||||
}
|
||||
|
||||
/*
|
||||
* set the ml generated label
|
||||
* Set the ml generated label - used for testing
|
||||
*/
|
||||
set mlLabel(label) {
|
||||
this.#suggestedMlLabel = label;
|
||||
|
||||
Reference in New Issue
Block a user