Commit 2f93295d authored by Chunchi Che's avatar Chunchi Che

Merge branch 'fix/modal' into 'main'

修复Modal开局弹出的问题

See merge request mycard/Neos!335
parents d724a676 6a1bc3c1
Pipeline #25423 passed with stages
in 12 minutes and 19 seconds
...@@ -2684,9 +2684,9 @@ ...@@ -2684,9 +2684,9 @@
} }
}, },
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001520", "version": "1.0.30001587",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001520.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001587.tgz",
"integrity": "sha512-tahF5O9EiiTzwTUqAeFjIZbn4Dnqxzz7ktrgGlMYNLH43Ul26IgTMH/zvL3DG0lZxBYnlT04axvInszUsZULdA==", "integrity": "sha512-HMFNotUmLXn71BQxg8cijvqxnIAofforZOwGsxyXJ0qugTdspUF4sPSJ2vhgprHCB996tIDzEq1ubumPDV8ULA==",
"funding": [ "funding": [
{ {
"type": "opencollective", "type": "opencollective",
...@@ -8908,9 +8908,9 @@ ...@@ -8908,9 +8908,9 @@
"dev": true "dev": true
}, },
"caniuse-lite": { "caniuse-lite": {
"version": "1.0.30001520", "version": "1.0.30001587",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001520.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001587.tgz",
"integrity": "sha512-tahF5O9EiiTzwTUqAeFjIZbn4Dnqxzz7ktrgGlMYNLH43Ul26IgTMH/zvL3DG0lZxBYnlT04axvInszUsZULdA==" "integrity": "sha512-HMFNotUmLXn71BQxg8cijvqxnIAofforZOwGsxyXJ0qugTdspUF4sPSJ2vhgprHCB996tIDzEq1ubumPDV8ULA=="
}, },
"chalk": { "chalk": {
"version": "4.1.2", "version": "4.1.2",
......
...@@ -19,6 +19,10 @@ ...@@ -19,6 +19,10 @@
} }
} }
.hidden {
visibility: hidden;
}
.wrap { .wrap {
pointer-events: none; pointer-events: none;
} }
......
...@@ -5,22 +5,24 @@ import { useEffect, useState } from "react"; ...@@ -5,22 +5,24 @@ import { useEffect, useState } from "react";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
interface Props extends ModalProps { export const NeosModal: React.FC<ModalProps> = (props) => {
canBeMinimized?: boolean;
}
export const NeosModal: React.FC<Props> = (props) => {
const { canBeMinimized = true } = props;
const [mini, setMini] = useState(false); const [mini, setMini] = useState(false);
// 为了修antd的bug,先让isOpen发生变化,再让它变回来 // 为了修antd的bug,先让isOpen发生变化,同时设置visibility为`hidden`,再让它变回来
const [realOpen, setRealOpen] = useState(true); const [realOpen, setRealOpen] = useState(true);
useEffect(() => setRealOpen(false), []); const [hidden, setHidden] = useState(true);
useEffect(() => {
setRealOpen(false);
setHidden(false);
}, []);
useEffect(() => setRealOpen(!!props.open), [props.open]); useEffect(() => setRealOpen(!!props.open), [props.open]);
return ( return (
<Modal <Modal
className={classNames(styles.modal, { [styles["mini"]]: mini })} className={classNames(styles.modal, {
[styles["mini"]]: mini,
[styles["hidden"]]: hidden,
})}
centered centered
maskClosable={true} maskClosable={true}
onCancel={() => setMini(!mini)} onCancel={() => setMini(!mini)}
...@@ -28,7 +30,7 @@ export const NeosModal: React.FC<Props> = (props) => { ...@@ -28,7 +30,7 @@ export const NeosModal: React.FC<Props> = (props) => {
bodyStyle={{ padding: "10px 0" }} bodyStyle={{ padding: "10px 0" }}
mask={!mini} mask={!mini}
wrapClassName={classNames({ [styles.wrap]: mini })} wrapClassName={classNames({ [styles.wrap]: mini })}
closable={canBeMinimized} closable={true}
{...props} {...props}
open={realOpen} open={realOpen}
/> />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment