Commit fd6fff8f authored by John Lee's avatar John Lee Committed by Commit Bot

Tab Strip WebUI: Check for more than 1 active tab

Bug: 989131
Change-Id: I6ff22ccbbfc876dc6f43a757b700fecd901b2325
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1848481
Commit-Queue: John Lee <johntlee@chromium.org>
Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704958}
parent 535458f6
...@@ -246,11 +246,17 @@ class TabListElement extends CustomElement { ...@@ -246,11 +246,17 @@ class TabListElement extends CustomElement {
* @private * @private
*/ */
onTabActivated_(tabId) { onTabActivated_(tabId) {
const previouslyActiveTab = this.getActiveTab_(); // There may be more than 1 TabElement marked as active if other events
if (previouslyActiveTab) { // have updated a Tab to have an active state. For example, if a
// tab is created with an already active state, there may be 2 active
// TabElements: the newly created tab and the previously active tab.
this.shadowRoot.querySelectorAll('tabstrip-tab[active]')
.forEach((previouslyActiveTab) => {
if (previouslyActiveTab.tab.id !== tabId) {
previouslyActiveTab.tab = /** @type {!TabData} */ ( previouslyActiveTab.tab = /** @type {!TabData} */ (
Object.assign({}, previouslyActiveTab.tab, {active: false})); Object.assign({}, previouslyActiveTab.tab, {active: false}));
} }
});
const newlyActiveTab = this.findTabElement_(tabId); const newlyActiveTab = this.findTabElement_(tabId);
if (newlyActiveTab) { if (newlyActiveTab) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment