From c697f8cd3522b1ec61cb8a97275a27d72032b663 Mon Sep 17 00:00:00 2001 From: aojunhao123 <1844749591@qq.com> Date: Mon, 12 Jan 2026 17:26:36 +0800 Subject: [PATCH] fix: popup container scroll due to precision --- .gitignore | 1 + src/hooks/useAlign.ts | 8 ++++---- tests/align.test.tsx | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index f44d17fe..584bc34c 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ es coverage yarn.lock package-lock.json +pnpm-lock.yaml bun.lockb # dumi diff --git a/src/hooks/useAlign.ts b/src/hooks/useAlign.ts index 6d478ff9..45c81f2b 100644 --- a/src/hooks/useAlign.ts +++ b/src/hooks/useAlign.ts @@ -677,13 +677,13 @@ export default function useAlign( popupMirrorRect.bottom - popupRect.y - (nextOffsetY + popupRect.height); if (scaleX === 1) { - nextOffsetX = Math.round(nextOffsetX); - offsetX4Right = Math.round(offsetX4Right); + nextOffsetX = Math.floor(nextOffsetX); + offsetX4Right = Math.floor(offsetX4Right); } if (scaleY === 1) { - nextOffsetY = Math.round(nextOffsetY); - offsetY4Bottom = Math.round(offsetY4Bottom); + nextOffsetY = Math.floor(nextOffsetY); + offsetY4Bottom = Math.floor(offsetY4Bottom); } const nextOffsetInfo = { diff --git a/tests/align.test.tsx b/tests/align.test.tsx index 945b132e..e6ce0c77 100644 --- a/tests/align.test.tsx +++ b/tests/align.test.tsx @@ -272,7 +272,7 @@ describe('Trigger.Align', () => { }); }); - it('round when decimal precision', async () => { + it('floor when decimal precision', async () => { rectX = 22.6; rectY = 33.4; rectWidth = 33.7; @@ -293,7 +293,7 @@ describe('Trigger.Align', () => { await awaitFakeTimer(); expect(document.querySelector('.rc-trigger-popup')).toHaveStyle({ - top: `56px`, + top: `55px`, }); }); });