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

fix: 容器可视宽度低于整体宽度进行切换时,下拉菜单无法显示隐藏的内容 #697

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
}
})
xiaozisong marked this conversation as resolved.
Show resolved Hide resolved
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
Loading