From 23209e79e98cf9b380fcfd2749eb2ca8f373a986 Mon Sep 17 00:00:00 2001 From: Connor Smith Date: Fri, 3 Oct 2025 13:33:11 -0400 Subject: [PATCH] [Enhancement] Set logo name from url --- frontend/src/components/forms/Logo.jsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/frontend/src/components/forms/Logo.jsx b/frontend/src/components/forms/Logo.jsx index cb7f385e..8362b891 100644 --- a/frontend/src/components/forms/Logo.jsx +++ b/frontend/src/components/forms/Logo.jsx @@ -210,6 +210,24 @@ const LogoForm = ({ logo = null, isOpen, onClose, onSuccess }) => { } }; + const handleUrlBlur = (event) => { + const urlValue = event.target.value; + if (urlValue) { + try { + const url = new URL(urlValue); + const pathname = url.pathname; + const filename = pathname.substring(pathname.lastIndexOf('/') + 1); + const nameWithoutExtension = filename.replace(/\.[^/.]+$/, ''); + if (nameWithoutExtension) { + formik.setFieldValue('name', nameWithoutExtension); + } + } catch (error) { + // If the URL is invalid, do nothing. + // The validation schema will catch this. + } + } + }; + // Clean up object URLs when component unmounts or preview changes useEffect(() => { return () => { @@ -322,6 +340,7 @@ const LogoForm = ({ logo = null, isOpen, onClose, onSuccess }) => { placeholder="https://example.com/logo.png" {...formik.getFieldProps('url')} onChange={handleUrlChange} + onBlur={handleUrlBlur} error={formik.touched.url && formik.errors.url} disabled={!!selectedFile} // Disable when file is selected />