Bug 1927910 - limit color changes when dragging to create tab groups r=dao,tabbrowser-reviewers

When all 9 tab group colors are in use, drag-drop code picks a random tab group color to highlight the tab drop target if the drop will create a tab group. The random pick is executed once per dragover event, so the color appears to change a few times a second. Kinda cool but distracting.

This patch chooses the next new tab group color on dragstart, saves that color on the drag data, and uses that color for all of the presentation + logic for creating a new tab group from a drop. The color will still be random when there are many tab groups, but the color will stay the same throughout a single drag operation.

Differential Revision: https://phabricator.services.mozilla.com/D228386
This commit is contained in:
Stephen Thompson 2024-11-08 10:04:07 +00:00
parent 00aba47a2c
commit ed23aca689

View File

@ -778,6 +778,7 @@
t => t.pinned == tab.pinned
),
fromTabList,
tabGroupCreationColor: gBrowser.tabGroupMenu.nextUnusedColor,
};
event.stopPropagation();
@ -1048,6 +1049,7 @@
gBrowser.addTabGroup([groupTab, ...movingTabs], {
insertBefore: draggedTab,
showCreateUI: true,
color: draggedTab._dragData.tabGroupCreationColor,
});
}
}
@ -2236,7 +2238,7 @@
"dragover-createGroup",
true
);
this.#setDragOverGroupColor(gBrowser.tabGroupMenu.nextUnusedColor);
this.#setDragOverGroupColor(dragData.tabGroupCreationColor);
} else {
this.removeAttribute("movingtab-createGroup");
}