Skip to content

Commit b6559f8

Browse files
authored
fix: popup container scroll due to precision (#603)
1 parent 1641cc2 commit b6559f8

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ es
2727
coverage
2828
yarn.lock
2929
package-lock.json
30+
pnpm-lock.yaml
3031
bun.lockb
3132

3233
# dumi

src/hooks/useAlign.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,13 +677,13 @@ export default function useAlign(
677677
popupMirrorRect.bottom - popupRect.y - (nextOffsetY + popupRect.height);
678678

679679
if (scaleX === 1) {
680-
nextOffsetX = Math.round(nextOffsetX);
681-
offsetX4Right = Math.round(offsetX4Right);
680+
nextOffsetX = Math.floor(nextOffsetX);
681+
offsetX4Right = Math.floor(offsetX4Right);
682682
}
683683

684684
if (scaleY === 1) {
685-
nextOffsetY = Math.round(nextOffsetY);
686-
offsetY4Bottom = Math.round(offsetY4Bottom);
685+
nextOffsetY = Math.floor(nextOffsetY);
686+
offsetY4Bottom = Math.floor(offsetY4Bottom);
687687
}
688688

689689
const nextOffsetInfo = {

tests/align.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ describe('Trigger.Align', () => {
272272
});
273273
});
274274

275-
it('round when decimal precision', async () => {
275+
it('floor when decimal precision', async () => {
276276
rectX = 22.6;
277277
rectY = 33.4;
278278
rectWidth = 33.7;
@@ -293,7 +293,7 @@ describe('Trigger.Align', () => {
293293
await awaitFakeTimer();
294294

295295
expect(document.querySelector('.rc-trigger-popup')).toHaveStyle({
296-
top: `56px`,
296+
top: `55px`,
297297
});
298298
});
299299
});

0 commit comments

Comments
 (0)