Skip to content

Commit 5025329

Browse files
committed
fix: restore editor focus after inserting markdown
1 parent 507910b commit 5025329

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

apps/client/src/widgets/dialogs/markdown_import.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,18 @@ export default function MarkdownImportDialog() {
3131
}
3232
});
3333

34-
async function sendForm() {
35-
if (textTypeWidget) {
36-
await convertMarkdownToHtml(text, textTypeWidget);
37-
}
38-
39-
setText("");
40-
setShown(false);
41-
}
42-
4334
return (
4435
<Modal
4536
className="markdown-import-dialog" title={t("markdown_import.dialog_title")} size="lg"
46-
footer={<Button className="markdown-import-button" text={t("markdown_import.import_button")} onClick={sendForm} keyboardShortcut="Ctrl+Enter" />}
37+
footer={<Button className="markdown-import-button" text={t("markdown_import.import_button")} onClick={() => setShown(false)} keyboardShortcut="Ctrl+Enter" />}
4738
onShown={() => markdownImportTextArea.current?.focus()}
48-
onHidden={() => setShown(false) }
39+
onHidden={async () => {
40+
if (textTypeWidget) {
41+
await convertMarkdownToHtml(text, textTypeWidget);
42+
}
43+
setShown(false);
44+
setText("");
45+
}}
4946
show={shown}
5047
>
5148
<p>{t("markdown_import.modal_body_text")}</p>
@@ -55,7 +52,7 @@ export default function MarkdownImportDialog() {
5552
onKeyDown={(e) => {
5653
if (e.key === "Enter" && e.ctrlKey) {
5754
e.preventDefault();
58-
sendForm();
55+
setShown(false);
5956
}
6057
}}></textarea>
6158
</Modal>

0 commit comments

Comments
 (0)