From 0ec3d62aced15e87a11ec670d115e98ce762a3d1 Mon Sep 17 00:00:00 2001 From: Michael Chihlas Date: Sat, 7 Mar 2026 22:32:56 -0500 Subject: [PATCH 1/3] refactor: enforce shared Modal component in remaining custom modals - ShareSessionModal: replaced custom modal markup with - CreateCategoryModal: replaced custom modal markup with - EditCategoryModal: replaced custom modal markup with - All now get focus trapping, Escape close, body scroll lock for free Co-Authored-By: Claude Opus 4.6 --- .../components/admin/CreateCategoryModal.tsx | 169 +++---- .../components/admin/EditCategoryModal.tsx | 168 +++---- .../components/session/ShareSessionModal.tsx | 469 +++++++++--------- 3 files changed, 379 insertions(+), 427 deletions(-) diff --git a/frontend/src/components/admin/CreateCategoryModal.tsx b/frontend/src/components/admin/CreateCategoryModal.tsx index adda04b5..4c2f5e33 100644 --- a/frontend/src/components/admin/CreateCategoryModal.tsx +++ b/frontend/src/components/admin/CreateCategoryModal.tsx @@ -1,6 +1,6 @@ import { useState } from 'react' -import { X } from 'lucide-react' import { cn } from '@/lib/utils' +import { Modal } from '@/components/common/Modal' interface CreateCategoryModalProps { isOpen: boolean @@ -19,8 +19,6 @@ export function CreateCategoryModal({ const [description, setDescription] = useState('') const [error, setError] = useState('') - if (!isOpen) return null - const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError('') @@ -40,7 +38,6 @@ export function CreateCategoryModal({ name: name.trim(), description: description.trim() }) - // Reset form on success setName('') setDescription('') } catch { @@ -58,102 +55,90 @@ export function CreateCategoryModal({ } return ( -
-
- {/* Header */} -
-

Create Category

+ +
- - {/* Form */} -
- {/* Error Message */} - {error && ( -
- {error} -
- )} - - {/* Name Field */} -
- - setName(e.target.value)} - disabled={isSaving} - maxLength={100} - placeholder="e.g., Network Troubleshooting" - required - className={cn( - 'w-full rounded-md border border-border bg-card px-3 py-2 text-sm text-foreground', - 'placeholder:text-muted-foreground', - 'focus:border-primary focus:outline-hidden focus:ring-1 focus:ring-primary/20', - 'disabled:opacity-50' - )} - /> -

- {name.length}/100 characters -

+ } + > + + {error && ( +
+ {error}
+ )} - {/* Description Field */} -
- -