Skip to content

Commit

Permalink
fix: modal double click open preview
Browse files Browse the repository at this point in the history
  • Loading branch information
Miracle575 committed Nov 8, 2023
1 parent 35e026b commit 8c3cb61
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions apps/portal-web/src/pageComponents/filemanager/RenameModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import { App, Form, Input, Modal } from "antd";
import { dirname, join } from "path";
import { useState } from "react";
import { useRef, useState } from "react";
import { api } from "src/apis";
import { prefix, useI18nTranslateToString } from "src/i18n";

Expand All @@ -37,6 +37,8 @@ export const RenameModal: React.FC<Props> = ({ open, onClose, path, reload, clus
const [form] = Form.useForm<FormProps>();
const [loading, setLoading] = useState(false);

const containerRef = useRef(null);

const t = useI18nTranslateToString();

const onSubmit = async () => {
Expand All @@ -54,24 +56,27 @@ export const RenameModal: React.FC<Props> = ({ open, onClose, path, reload, clus
};

return (
<Modal
open={open}
title={t(p("title"))}
okText={t("button.confirmButton")}
cancelText={t("button.cancelButton")}
onCancel={onClose}
confirmLoading={loading}
destroyOnClose
onOk={form.submit}
>
<Form form={form} onFinish={onSubmit}>
<Form.Item label={t(p("renameLabel"))}>
<strong>{path}</strong>
</Form.Item>
<Form.Item<FormProps> label={t(p("newFileName"))} name="newFileName" rules={[{ required: true }]}>
<Input />
</Form.Item>
</Form>
</Modal>
<div ref={containerRef} onDoubleClick={(event) => event.stopPropagation()}>
<Modal
open={open}
title={t(p("title"))}
okText={t("button.confirmButton")}
cancelText={t("button.cancelButton")}
onCancel={onClose}
confirmLoading={loading}
destroyOnClose
onOk={form.submit}
getContainer={containerRef.current || false}
>
<Form form={form} onFinish={onSubmit}>
<Form.Item label={t(p("renameLabel"))}>
<strong>{path}</strong>
</Form.Item>
<Form.Item<FormProps> label={t(p("newFileName"))} name="newFileName" rules={[{ required: true }]}>
<Input />
</Form.Item>
</Form>
</Modal>
</div>
);
};

0 comments on commit 8c3cb61

Please sign in to comment.