Skip to content

Commit 448b337

Browse files
committed
test: add test case
1 parent 2b95517 commit 448b337

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

src/hooks/useAlign.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -644,13 +644,9 @@ export default function useAlign(
644644

645645
// Additional calculate right & bottom position
646646
const offsetX4Right =
647-
popupMirrorRect.right -
648-
popupRect.left -
649-
(nextOffsetX + popupRect.width);
647+
popupMirrorRect.right - popupRect.x - (nextOffsetX + popupRect.width);
650648
const offsetY4Bottom =
651-
popupMirrorRect.bottom -
652-
popupRect.top -
653-
(nextOffsetY + popupRect.height);
649+
popupMirrorRect.bottom - popupRect.y - (nextOffsetY + popupRect.height);
654650

655651
setOffsetInfo({
656652
ready: true,

tests/align.test.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ describe('Trigger.Align', () => {
2323
y: 100,
2424
width: 100,
2525
height: 100,
26+
right: 200,
27+
bottom: 200,
2628
}),
2729
});
2830

@@ -233,4 +235,27 @@ describe('Trigger.Align', () => {
233235
top: `50px`,
234236
});
235237
});
238+
239+
it('support dynamicInset', async () => {
240+
render(
241+
<Trigger
242+
popupVisible
243+
popup={<span className="bamboo" />}
244+
popupAlign={{
245+
points: ['bc', 'tc'],
246+
_experimental: {
247+
dynamicInset: true,
248+
},
249+
}}
250+
>
251+
<div />
252+
</Trigger>,
253+
);
254+
255+
await awaitFakeTimer();
256+
257+
expect(document.querySelector('.rc-trigger-popup')).toHaveStyle({
258+
bottom: `100px`,
259+
});
260+
});
236261
});

0 commit comments

Comments
 (0)