浏览代码

fix: fix body scroll unreset when unmount modal directly(#2023)

代强 1 年之前
父节点
当前提交
d6f86a3405
共有 2 个文件被更改,包括 6 次插入0 次删除
  1. 4 0
      packages/semi-foundation/modal/modalFoundation.ts
  2. 2 0
      packages/semi-ui/modal/Modal.tsx

+ 4 - 0
packages/semi-foundation/modal/modalFoundation.ts

@@ -111,6 +111,10 @@ export default class ModalFoundation extends BaseFoundation<ModalAdapter> {
         this._adapter.notifyClose();
     }
 
+    enabledBodyScroll() {
+        this._adapter.enabledBodyScroll();
+    }
+
     // afterClose() {
     //     this._adapter.notifyClose();
     // }

+ 2 - 0
packages/semi-ui/modal/Modal.tsx

@@ -243,6 +243,8 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
     componentWillUnmount() {
         if (this.props.visible) {
             this.foundation.destroy();
+        } else {
+            this.foundation.enabledBodyScroll();
         }
     }