Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate key in tabs overflow menu #444

Open
rinick opened this issue Nov 12, 2021 · 3 comments
Open

duplicate key in tabs overflow menu #444

rinick opened this issue Nov 12, 2021 · 3 comments

Comments

@rinick
Copy link
Contributor

rinick commented Nov 12, 2021

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;
}
@rinick
Copy link
Contributor Author

rinick commented Nov 12, 2021

you can reproduce it in the above example.

also it only happens for 1 or 2 frames, and when you actually open the dropdown, you will never see the duplicated item.

So it might also be some timing issue between react hooks that messed up with the measuring.

@afc163
Copy link
Member

afc163 commented Dec 8, 2021

PR is welcome

@mahileeb
Copy link

Can we get the PR merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants