This commit is contained in:
Zacharias-Brohn
2026-01-14 21:54:30 +01:00
parent 33074c420a
commit 95d07eb00b
+17 -2
View File
@@ -39,7 +39,6 @@ import { getInstalledModels, type OllamaModel } from '@/app/actions/ollama';
import { useThemeContext } from '@/components/DynamicThemeProvider'; import { useThemeContext } from '@/components/DynamicThemeProvider';
import { SettingsModal } from '@/components/Settings/SettingsModal'; import { SettingsModal } from '@/components/Settings/SettingsModal';
import { import {
addMessageToLocalChat,
deleteLocalChat, deleteLocalChat,
deleteScrollPosition, deleteScrollPosition,
getLocalChat, getLocalChat,
@@ -116,6 +115,7 @@ export default function ChatLayout() {
const [editingChatId, setEditingChatId] = useState<string | null>(null); const [editingChatId, setEditingChatId] = useState<string | null>(null);
const [editingTitle, setEditingTitle] = useState(''); const [editingTitle, setEditingTitle] = useState('');
const editInputRef = useRef<HTMLInputElement>(null); const editInputRef = useRef<HTMLInputElement>(null);
const justStartedEditing = useRef(false);
// Scroll state // Scroll state
const scrollViewportRef = useRef<HTMLDivElement>(null); const scrollViewportRef = useRef<HTMLDivElement>(null);
@@ -416,14 +416,29 @@ export default function ChatLayout() {
if (!chat) { if (!chat) {
return; return;
} }
// Small delay to let the menu close first before entering edit mode
setTimeout(() => {
justStartedEditing.current = true;
setEditingChatId(chatId); setEditingChatId(chatId);
setEditingTitle(chat.title); setEditingTitle(chat.title);
// Focus the input after React renders // Focus the input after React renders
setTimeout(() => editInputRef.current?.focus(), 0); setTimeout(() => {
editInputRef.current?.focus();
editInputRef.current?.select();
// Allow blur to work after a short delay
setTimeout(() => {
justStartedEditing.current = false;
}, 100);
}, 0);
}, 50);
}; };
// Save the renamed chat title // Save the renamed chat title
const saveRenamedChat = async () => { const saveRenamedChat = async () => {
// Skip if we just started editing (prevents immediate blur from closing)
if (justStartedEditing.current) {
return;
}
if (!editingChatId) { if (!editingChatId) {
return; return;
} }