diff --git a/libs/components/editor-blocks/src/components/upload/upload.tsx b/libs/components/editor-blocks/src/components/upload/upload.tsx index 190b4f4f31..1fa2f20092 100644 --- a/libs/components/editor-blocks/src/components/upload/upload.tsx +++ b/libs/components/editor-blocks/src/components/upload/upload.tsx @@ -3,6 +3,7 @@ import { MuiBox as Box, MuiButton as Button, MuiClickAwayListener as ClickAwayListener, + MuiPopper, MuiTab as Tab, MuiTabs as Tabs, MuiTextField as TextField, @@ -15,6 +16,7 @@ import { SyntheticEvent, useRef, useState, + type MouseEvent, } from 'react'; const MESSAGES = { @@ -36,11 +38,11 @@ interface Props { } const styles: SxProps = { position: 'absolute', - width: '70%', + width: '600px', // maxWidth:'100%', - zIndex: 999, - marginLeft: '50px', - p: 1, + // The z-index of refPage is 200, + // so the z-index of upload need to be greater than it + zIndex: 201, bgcolor: 'background.paper', borderRadius: '4px', textAlign: 'center', @@ -85,21 +87,22 @@ export const Upload = (props: Props) => { } = props; const input_ref = useRef(null); const [upload_link, set_upload_link] = useState(''); - - const [open, setOpen] = useState(firstCreate); const type = ['file', 'image'].includes(uploadType) ? 'file' : 'link'; const [value, setValue] = useState(type); + const [anchorEl, setAnchorEl] = useState(null); + const open = Boolean(anchorEl); + const handleChange = (event: SyntheticEvent, newValue: string) => { setValue(newValue); }; - const handleClick = () => { - setOpen(prev => !prev); + const handleClick = (event: MouseEvent) => { + setAnchorEl(anchorEl ? null : event.currentTarget); }; const handleClickAway = () => { - setOpen(false); + setAnchorEl(null); }; const choose_file = () => { if (input_ref.current) { @@ -127,128 +130,126 @@ export const Upload = (props: Props) => { savaLink(upload_link); }; return ( -
- - - {defaultAddBtnText - ? defaultAddBtnText - : MESSAGES.ADD_AN_FILE} - + + {defaultAddBtnText ? defaultAddBtnText : MESSAGES.ADD_AN_FILE} + { + e.stopPropagation(); + deleteFile(); + }} + > + + + + {open && ( + + { e.stopPropagation(); - deleteFile(); }} + sx={styles} > - - - - {open && ( - - { - e.stopPropagation(); - }} - sx={styles} + value={value} + onChange={handleChange} > - - {['file', 'image'].includes(uploadType) ? ( - - ) : ( - '' - )} - {!['file', 'image'].includes(uploadType) ? ( - - ) : ( - '' - )} - - - {value === 'file' ? ( - - - - + {['file', 'image'].includes(uploadType) ? ( + ) : ( - - - - - - + '' )} - - - )} - -
+ {!['file', 'image'].includes(uploadType) ? ( + + ) : ( + '' + )} + + + {value === 'file' ? ( + + + + + ) : ( + + + + + + + )} + + + )} + ); };