diff --git a/frontend/src/components/admin/AdminPhotoGrid.tsx b/frontend/src/components/admin/AdminPhotoGrid.tsx index 64485699..d482a25a 100644 --- a/frontend/src/components/admin/AdminPhotoGrid.tsx +++ b/frontend/src/components/admin/AdminPhotoGrid.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useState } from 'react'; import { Check, Download, Trash2, Eye, EyeOff, Heart, Package, MessageSquare, Star, Video, FolderOpen, Cog, AlertTriangle, RefreshCw, LayoutGrid, List } from 'lucide-react'; import { toast } from 'react-toastify'; import { useQueryClient } from '@tanstack/react-query'; @@ -47,9 +47,13 @@ export const AdminPhotoGrid: React.FC = ({ // Layout toggle (Grid / List) persisted per admin via localStorage. const [viewMode, setViewMode] = useState(() => getPhotoViewMode()); - useEffect(() => { - setPhotoViewMode(viewMode); - }, [viewMode]); + // Persist on user action only — writing in an effect would re-save the + // value on every mount (i.e. each time the Photos tab is opened), even + // when the user never touched the toggle. + const selectView = (mode: PhotoViewMode) => { + setViewMode(mode); + setPhotoViewMode(mode); + }; const handlePhotoSelect = (photoId: number, e?: React.MouseEvent) => { if (e) { @@ -259,12 +263,14 @@ export const AdminPhotoGrid: React.FC = ({
{t('gallery.photosCount', { count: photos.length })}
- {/* Layout toggle: Grid / List */} -
+ {/* Layout toggle: Grid / List — radiogroup so a screen reader + announces the two options as one mutually-exclusive set. */} +