Skip to content

Commit

Permalink
fix: fix modal popupContainer return body (#2335)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaiQiangReal authored Jul 12, 2024
1 parent cc3d610 commit a65aac2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/semi-ui/modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
disabledBodyScroll: () => {
const { getPopupContainer } = this.props;
this.bodyOverflow = document.body.style.overflow || '';
if (!getPopupContainer && this.bodyOverflow !== 'hidden') {
if ((!getPopupContainer || getPopupContainer() === document.body) && this.bodyOverflow !== 'hidden') {
document.body.style.overflow = 'hidden';
document.body.style.width = `calc(${this.originBodyWidth || '100%'} - ${this.scrollBarWidth}px)`;
}
},
enabledBodyScroll: () => {
const { getPopupContainer } = this.props;
if (!getPopupContainer && this.bodyOverflow !== null && this.bodyOverflow !== 'hidden') {
if ((!getPopupContainer || getPopupContainer() === document.body) && this.bodyOverflow !== null && this.bodyOverflow !== 'hidden') {
document.body.style.overflow = this.bodyOverflow;
document.body.style.width = this.originBodyWidth;
}
Expand Down Expand Up @@ -354,7 +354,7 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
} = {
zIndex,
};
if (getPopupContainer) {
if (getPopupContainer && getPopupContainer() !== document.body) {
wrapperStyle = {
zIndex,
position: 'static',
Expand Down
2 changes: 1 addition & 1 deletion packages/semi-ui/modal/ModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export default class ModalContent extends BaseComponent<ModalContentReactProps,
} = this.props;
const { direction } = this.context;
const classList = cls(className, {
[`${cssClasses.DIALOG}-popup`]: getPopupContainer && !maskFixed,
[`${cssClasses.DIALOG}-popup`]: getPopupContainer && getPopupContainer() !== document.body && !maskFixed,
[`${cssClasses.DIALOG}-fixed`]: maskFixed,
[`${cssClasses.DIALOG}-rtl`]: direction === 'rtl',
});
Expand Down

0 comments on commit a65aac2

Please sign in to comment.