diff --git a/src/photo/PhotoEditPageClient.tsx b/src/photo/PhotoEditPageClient.tsx index dfea98cd..9c58016f 100644 --- a/src/photo/PhotoEditPageClient.tsx +++ b/src/photo/PhotoEditPageClient.tsx @@ -28,6 +28,7 @@ export default function PhotoEditPageClient({ ); const [pending, setIsPending] = useState(false); + const [updatedTitle, setUpdatedTitle] = useState(''); const hasExifDataBeenFound = !areSimpleObjectsEqual( updatedExifData, @@ -38,7 +39,9 @@ export default function PhotoEditPageClient({ @@ -59,6 +62,7 @@ export default function PhotoEditPageClient({ ? updatedExifData : undefined} uniqueTags={uniqueTags} + onTitleChange={setUpdatedTitle} onFormStatusChange={setIsPending} /> diff --git a/src/photo/UploadPageClient.tsx b/src/photo/UploadPageClient.tsx index b943e7ef..e5e6a0c6 100644 --- a/src/photo/UploadPageClient.tsx +++ b/src/photo/UploadPageClient.tsx @@ -17,17 +17,21 @@ export default function UploadPageClient({ uniqueTags: TagsWithMeta }) { const [pending, setIsPending] = useState(false); + const [updatedTitle, setUpdatedTitle] = useState(''); return ( diff --git a/src/photo/form/PhotoForm.tsx b/src/photo/form/PhotoForm.tsx index 13da62bd..96f928be 100644 --- a/src/photo/form/PhotoForm.tsx +++ b/src/photo/form/PhotoForm.tsx @@ -34,6 +34,7 @@ export default function PhotoForm({ type = 'create', uniqueTags, debugBlur, + onTitleChange, onFormStatusChange, }: { initialPhotoForm: Partial @@ -41,6 +42,7 @@ export default function PhotoForm({ type?: 'create' | 'edit' uniqueTags?: TagsWithMeta debugBlur?: boolean + onTitleChange?: (updatedTitle: string) => void onFormStatusChange?: (pending: boolean) => void }) { const [formData, setFormData] = @@ -86,7 +88,7 @@ export default function PhotoForm({ } = getDimensionsFromSize(THUMBNAIL_SIZE, formData.aspectRatio); // Generate local date strings when - // none can be harvested from EXIF + // none can be extracted from EXIF useEffect(() => { if (!formData.takenAt || !formData.takenAtNaive) { setFormData(data => ({ @@ -188,6 +190,9 @@ export default function PhotoForm({ if (validate) { setFormErrors({ ...formErrors, [key]: validate(value) }); } + if (key === 'title') { + onTitleChange?.(value.trim()); + } }} selectOptions={selectOptions} selectOptionsDefaultLabel={selectOptionsDefaultLabel}