Skip to content

Commit e2c1be9

Browse files
author
皆虚
committed
fix(Overlay): bug on postion when bottom overflow
1 parent 090e88b commit e2c1be9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/overlay/utils/position.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,15 @@ export default class Position {
178178
if (this._isInViewport(pinElement, align)) {
179179
return align;
180180
} else if (!firstPositionResult) {
181-
const { right, bottom } = this._getViewportOffset(pinElement, align);
182-
firstPositionResult = { left: right < 0 ? left + right : left, top: top < 0 ? top + bottom : top };
181+
if (this.needAdjust && !this.autoFit) {
182+
const { right, bottom } = this._getViewportOffset(pinElement, align);
183+
firstPositionResult = {
184+
left: right < 0 ? left + right : left,
185+
top: bottom < 0 ? top + bottom : top,
186+
};
187+
} else {
188+
firstPositionResult = { left, top };
189+
}
183190
}
184191
}
185192

test/overlay/index-spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ describe('Overlay', () => {
600600
<div
601601
style={{
602602
width: '200px',
603+
height: '100vh',
603604
background: 'red',
604605
}}
605606
>
@@ -615,6 +616,7 @@ describe('Overlay', () => {
615616
document.querySelector('.next-overlay-inner').style.left ===
616617
`${parseFloat(window.getComputedStyle(document.body).width) - 200 - 1}px` // Reason to subtract 1, see: Overly._isInViewport
617618
);
619+
assert(document.querySelector('.next-overlay-inner').style.top === '0px');
618620
container.remove();
619621
document.querySelector('.next-overlay-wrapper').remove();
620622
});

0 commit comments

Comments
 (0)