Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/TabNavList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ function TabNavList(props: TabNavListProps, ref: React.Ref<HTMLDivElement>) {
addSizeValue,
// Operation
operationSizeValue,
containerExcludeExtraSizeValue,
activeKey,
{ ...props, tabs },
);

Expand Down
12 changes: 12 additions & 0 deletions src/hooks/useVisibleRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export default function useVisibleRange(
tabContentSizeValue: number,
addNodeSizeValue: number,
operationNodeSizeValue: number,
containerExcludeExtraSizeValue: number,
activeKey: string,
{ tabs, tabPosition, rtl }: { tabs: Tab[] } & TabNavListProps,
): [visibleStart: number, visibleEnd: number] {
let charUnit: 'width' | 'height';
Expand All @@ -34,6 +36,16 @@ export default function useVisibleRange(
return [0, 0];
}

if (containerExcludeExtraSizeValue < tabContentSizeValue) {
let filterIndex
tabs.forEach((item, index) => {
if ((item.tabKey || item.key) === activeKey) {
filterIndex = index
}
})
return [filterIndex, filterIndex]
}
Copy link
Member

@afc163 afc163 Jan 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

能帮忙补一个测试用例不?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我看overflow.test.tsx中的should calculate hidden tabs correctly用例应该可以覆盖这种情况吧

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那为啥原来的测试用例没挂呢?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那我试着补一个


const len = tabs.length;
let endIndex = len;
for (let i = 0; i < len; i += 1) {
Expand Down