-
+
+
);
};
diff --git a/src/components/link-input-modal.js b/src/components/link-input-modal.js
index ff28a42..2a5a490 100644
--- a/src/components/link-input-modal.js
+++ b/src/components/link-input-modal.js
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useRef, useState } from 'react';
import PropTypes from 'prop-types';
import { useTranslation } from '@/lib/i18n';
import { isValidUrl } from '@/lib/url';
@@ -13,6 +13,8 @@ const LinkInputModal = ({ isOpen, onClose, onConfirm }) => {
const [openInNewTab, setOpenInNewTab] = useState(true);
const [displayError, setDisplayError] = useState('');
const [urlError, setUrlError] = useState('');
+ const displayRef = useRef(null);
+ const urlRef = useRef(null);
const t = useTranslation('link-input-modal');
const resetForm = () => {
@@ -37,7 +39,11 @@ const LinkInputModal = ({ isOpen, onClose, onConfirm }) => {
if (isDisplayEmpty) setDisplayError(t('displayRequiredError'));
if (isUrlEmpty) setUrlError(t('urlRequiredError'));
else if (isUrlInvalid) setUrlError(t('urlInvalidError'));
- if (isDisplayEmpty || isUrlEmpty || isUrlInvalid) return;
+ if (isDisplayEmpty || isUrlEmpty || isUrlInvalid) {
+ if (isDisplayEmpty) displayRef.current?.focus();
+ else urlRef.current?.focus();
+ return;
+ }
const prefix = openInNewTab ? '@' : '';
const titlePart = title.trim() ? `[[${title.trim()}]]` : '';
@@ -46,18 +52,25 @@ const LinkInputModal = ({ isOpen, onClose, onConfirm }) => {
handleClose();
};
+ const handleFormSubmit = (e) => {
+ e.preventDefault();
+ handleConfirm();
+ };
+
return (