Auto-select first story when navigating to Stories tab

This commit is contained in:
Jamie Pine
2026-03-14 11:14:46 -07:00
parent 310a4acb02
commit 626e3740e1
+8 -1
View File
@@ -1,5 +1,5 @@
import { BookOpen, MoreHorizontal, Pencil, Plus, Trash2 } from 'lucide-react';
import { useState } from 'react';
import { useEffect, useState } from 'react';
import {
AlertDialog,
AlertDialogAction,
@@ -62,6 +62,13 @@ export function StoryList() {
const [newStoryDescription, setNewStoryDescription] = useState('');
const { toast } = useToast();
// Auto-select the first story when the list loads with no selection
useEffect(() => {
if (!selectedStoryId && stories && stories.length > 0) {
setSelectedStoryId(stories[0].id);
}
}, [selectedStoryId, stories, setSelectedStoryId]);
const handleCreateStory = () => {
if (!newStoryName.trim()) {
toast({