Browse Source

Revert changes

arvid-e 2 weeks ago
parent
commit
73bdb5272e

+ 5 - 21
apps/app/src/client/components/Admin/MarkdownSetting/ContentDispositionSettings.tsx

@@ -1,5 +1,5 @@
 import type React from 'react';
 import type React from 'react';
-import { useCallback, useEffect, useRef, useState } from 'react';
+import { useCallback, useEffect, useState } from 'react';
 import { useTranslation } from 'next-i18next';
 import { useTranslation } from 'next-i18next';
 import { useForm } from 'react-hook-form';
 import { useForm } from 'react-hook-form';
 
 
@@ -70,7 +70,6 @@ const ContentDispositionSettings: React.FC = () => {
 
 
   const [currentInput, setCurrentInput] = useState<string>('');
   const [currentInput, setCurrentInput] = useState<string>('');
   const [error, setError] = useState<string | null>(null);
   const [error, setError] = useState<string | null>(null);
-  const isManualSubmit = useRef(false);
 
 
   const {
   const {
     handleSubmit,
     handleSubmit,
@@ -95,10 +94,7 @@ const ContentDispositionSettings: React.FC = () => {
   const attachmentMimeTypes = watch('attachmentMimeTypes');
   const attachmentMimeTypes = watch('attachmentMimeTypes');
 
 
   const handleSetMimeType = useCallback(
   const handleSetMimeType = useCallback(
-    (disposition: 'inline' | 'attachment', event: React.MouseEvent) => {
-      event.preventDefault();
-      event.stopPropagation();
-
+    (disposition: 'inline' | 'attachment') => {
       const mimeType = normalizeMimeType(currentInput);
       const mimeType = normalizeMimeType(currentInput);
       if (!mimeType) return;
       if (!mimeType) return;
 
 
@@ -139,10 +135,6 @@ const ContentDispositionSettings: React.FC = () => {
   );
   );
 
 
   const onSubmit = async (data: ContentDispositionSettingsType) => {
   const onSubmit = async (data: ContentDispositionSettingsType) => {
-    if (!isManualSubmit.current) {
-      return;
-    }
-
     try {
     try {
       setError(null);
       setError(null);
       await updateSettings(data);
       await updateSettings(data);
@@ -164,7 +156,7 @@ const ContentDispositionSettings: React.FC = () => {
   if (isLoading && !currentSettings) return <div>Loading...</div>;
   if (isLoading && !currentSettings) return <div>Loading...</div>;
 
 
   return (
   return (
-    <form className="row" onSubmit={handleSubmit(onSubmit)}>
+    <div className="row">
       <div className="col-12">
       <div className="col-12">
         <h2 className="mb-4 border-0">
         <h2 className="mb-4 border-0">
           {t('markdown_settings.content-disposition_header')}
           {t('markdown_settings.content-disposition_header')}
@@ -183,11 +175,6 @@ const ContentDispositionSettings: React.FC = () => {
                   value={currentInput}
                   value={currentInput}
                   onChange={(e) => setCurrentInput(e.target.value)}
                   onChange={(e) => setCurrentInput(e.target.value)}
                   placeholder="e.g. image/png"
                   placeholder="e.g. image/png"
-                  onKeyDown={(e) => {
-                    if (e.key === 'Enter') {
-                      e.preventDefault();
-                    }
-                  }}
                 />
                 />
                 <button
                 <button
                   className="btn btn-primary px-3 flex-shrink-0 rounded-3 fw-bold"
                   className="btn btn-primary px-3 flex-shrink-0 rounded-3 fw-bold"
@@ -251,14 +238,11 @@ const ContentDispositionSettings: React.FC = () => {
         </div>
         </div>
 
 
         <AdminUpdateButtonRow
         <AdminUpdateButtonRow
-          onClick={() => {
-            isManualSubmit.current = true;
-            handleSubmit(onSubmit)();
-          }}
+          onClick={handleSubmit(onSubmit)}
           disabled={!isDirty || isUpdating}
           disabled={!isDirty || isUpdating}
         />
         />
       </div>
       </div>
-    </form>
+    </div>
   );
   );
 };
 };