mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-22 11:15:23 -04:00
Update to cypress 9 and fix firefox upload crash (#1653)
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> Co-authored-by: Renovate Bot <bot@renovateapp.com>
This commit is contained in:
parent
d4251519e2
commit
03725f5512
11 changed files with 80 additions and 58 deletions
|
@ -43,7 +43,7 @@ export const ImportMarkdownSidebarEntry: React.FC = () => {
|
|||
|
||||
return (
|
||||
<Fragment>
|
||||
<SidebarButton {...cypressId('menu-import-markdown')} icon={'file-text-o'} onClick={buttonClick}>
|
||||
<SidebarButton {...cypressId('menu-import-markdown-button')} icon={'file-text-o'} onClick={buttonClick}>
|
||||
<Trans i18nKey={'editor.import.file'} />
|
||||
</SidebarButton>
|
||||
<UploadInput
|
||||
|
|
|
@ -21,11 +21,12 @@ export interface UploadInputProps extends PropsWithDataCypressId {
|
|||
export const UploadInput: React.FC<UploadInputProps> = ({ onLoad, acceptedFiles, onClickRef, ...props }) => {
|
||||
const fileInputReference = useRef<HTMLInputElement>(null)
|
||||
const onClick = useCallback(() => {
|
||||
const fileInput = fileInputReference.current
|
||||
if (!fileInput) {
|
||||
return
|
||||
}
|
||||
fileInput.addEventListener('change', () => {
|
||||
fileInputReference.current?.click()
|
||||
}, [])
|
||||
|
||||
const onChange = useCallback<React.ChangeEventHandler<HTMLInputElement>>(
|
||||
(event) => {
|
||||
const fileInput = event.currentTarget
|
||||
if (!fileInput.files || fileInput.files.length < 1) {
|
||||
return
|
||||
}
|
||||
|
@ -37,13 +38,22 @@ export const UploadInput: React.FC<UploadInputProps> = ({ onLoad, acceptedFiles,
|
|||
.catch((error: Error) => {
|
||||
log.error('Error while uploading file', error)
|
||||
})
|
||||
})
|
||||
fileInput.click()
|
||||
}, [onLoad])
|
||||
},
|
||||
[onLoad]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
onClickRef.current = onClick
|
||||
})
|
||||
|
||||
return <input {...cypressId(props)} type='file' ref={fileInputReference} className='d-none' accept={acceptedFiles} />
|
||||
return (
|
||||
<input
|
||||
{...cypressId(props)}
|
||||
onChange={onChange}
|
||||
type='file'
|
||||
ref={fileInputReference}
|
||||
className='d-none'
|
||||
accept={acceptedFiles}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue