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: offset四舍五入导致hiddenTabs计算逻辑错误 #667

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion src/TabNavList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ function TabNavList(props: TabNavListProps, ref: React.Ref<HTMLDivElement>) {
setTabSizes(() => {
const newSizes: TabSizeMap = new Map();
tabs.forEach(({ key }) => {
const btnNode = tabListRef.current?.querySelector<HTMLElement>(`[data-node-key="${genDataNodeKey(key)}"]`);
const btnNode = tabListRef.current?.querySelector<HTMLElement>(
`[data-node-key="${genDataNodeKey(key)}"]`,
);
if (btnNode) {
newSizes.set(key, {
width: btnNode.offsetWidth,
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useVisibleRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function useVisibleRange(
let endIndex = len;
for (let i = 0; i < len; i += 1) {
const offset = tabOffsets.get(tabs[i].key) || DEFAULT_SIZE;
if (offset[position] + offset[charUnit] > transformSize + visibleTabContentValue) {
if (offset[position] + offset[charUnit] - 2 > transformSize + visibleTabContentValue) {
endIndex = i - 1;
break;
}
Expand Down