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:
Nick Grato
2025-03-06 15:38:51 +00:00
parent f66d571349
commit 207d8697bf
2 changed files with 34 additions and 28 deletions

View File

@@ -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;