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