Skip to content

duplicate key in tabs overflow menu #444

Open
@rinick

Description

@rinick

in this function, sometimes the startIndex is bigger than the endIndex, causing the menu for hiddenTabs in TabNavList to have duplicated items.
I guess some tab extra element with user defined css can cause it to measure things incorrectly.

const len = tabs.length;
let endIndex = len;
for (let i = 0; i < len; i += 1) {
const offset = tabOffsets.get(tabs[i].key) || DEFAULT_SIZE;
if (offset[position] + offset[unit] > transformSize + mergedBasicSize) {
endIndex = i - 1;
break;
}
}
let startIndex = 0;
for (let i = len - 1; i >= 0; i -= 1) {
const offset = tabOffsets.get(tabs[i].key) || DEFAULT_SIZE;
if (offset[position] < transformSize) {
startIndex = i + 1;
break;
}
}
return [startIndex, endIndex];

could we add a simple protection like

if (startIndex > endIndex) {
  endIndex = startIndex;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions