Commit 66018d30 authored by chenshouchao's avatar chenshouchao

feat: 任务名称为空校验,气泡确认组件点击空白取消

parent 45239ce4
import * as React from "react"; import * as React from "react";
import { ReactNode } from "react"; import { ReactNode, useEffect } from "react";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import ButtonComponent from "./Button"; import ButtonComponent from "./Button";
import tipsIcon from "@/assets/project/information-outline.svg"; import tipsIcon from "@/assets/project/information-outline.svg";
...@@ -28,7 +28,7 @@ const MyPopconfirm = (props: IMyPopconfirmProps) => { ...@@ -28,7 +28,7 @@ const MyPopconfirm = (props: IMyPopconfirmProps) => {
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null); const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const handleClick = (event: React.MouseEvent<HTMLElement>) => { const handleClick = (event: React.MouseEvent<HTMLElement>) => {
console.log(123); event.nativeEvent.stopImmediatePropagation();
setAnchorEl(anchorEl ? null : event.currentTarget); setAnchorEl(anchorEl ? null : event.currentTarget);
}; };
...@@ -45,6 +45,12 @@ const MyPopconfirm = (props: IMyPopconfirmProps) => { ...@@ -45,6 +45,12 @@ const MyPopconfirm = (props: IMyPopconfirmProps) => {
onConfirm && onConfirm(); onConfirm && onConfirm();
}; };
useEffect(() => {
document.addEventListener("click", (e) => {
setAnchorEl(null);
});
}, []);
return ( return (
<div> <div>
<div aria-describedby={id} onClick={handleClick}> <div aria-describedby={id} onClick={handleClick}>
......
...@@ -97,7 +97,13 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -97,7 +97,13 @@ const ConfigForm = (props: ConfigFormProps) => {
const checkName = (name: string = "") => { const checkName = (name: string = "") => {
const reg = new RegExp(/^[a-zA-Z0-9\u4e00-\u9fa5-_]{3,30}$/); const reg = new RegExp(/^[a-zA-Z0-9\u4e00-\u9fa5-_]{3,30}$/);
if (reg.test(name)) { if (!name) {
setNameHelp({
error: true,
helperText: "任务名称不能为空",
});
return true;
} else if (reg.test(name)) {
setNameHelp({ setNameHelp({
error: false, error: false,
helperText: "", helperText: "",
......
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