Simplify focus logic, fix index existence checks, and remove textarea autoFocus to improve UX and stability
This commit is contained in:
@@ -30,7 +30,7 @@ interface Scratch {
|
||||
}
|
||||
|
||||
const MEILISEARCH_ENDPOINT = 'https://meili.site.quack-lab.dev/';
|
||||
const MEILISEARCH_API_KEY = 'F46V628fnzK85P376Q95n7987Z95M2MG673ea325982tD9v7236ix8XH54Xx26q6';
|
||||
const MEILISEARCH_API_KEY = '31qXgGbQ3lT4DYHQ0TOKpMzh7wcigs7agHyxP5Fz6T6D61xsvNr24uO8ifndKOfM';
|
||||
const NOTE_INDEX = 'notes';
|
||||
const SCRATCH_INDEX = 'scratch';
|
||||
const SETTINGS_INDEX = 'settings';
|
||||
@@ -633,9 +633,7 @@ const Index = () => {
|
||||
if (e.ctrlKey && e.key === 'f') {
|
||||
e.preventDefault();
|
||||
setIsSearchOpen(true);
|
||||
setTimeout(() => {
|
||||
searchInputRef.current?.focus();
|
||||
}, 100);
|
||||
} else if (e.key === 'Escape') {
|
||||
e.preventDefault();
|
||||
// Save current note if it has content
|
||||
@@ -674,15 +672,6 @@ const Index = () => {
|
||||
};
|
||||
}, [currentNote, previousNote, scratchPad, isPreviousNoteModified]);
|
||||
|
||||
// Focus search input when dialog opens
|
||||
useEffect(() => {
|
||||
if (isSearchOpen) {
|
||||
setTimeout(() => {
|
||||
searchInputRef.current?.focus();
|
||||
}, 100);
|
||||
}
|
||||
}, [isSearchOpen]);
|
||||
|
||||
// Auto-save functions
|
||||
const handleCurrentNoteBlur = () => {
|
||||
if (currentNote.trim()) {
|
||||
@@ -810,7 +799,7 @@ const Index = () => {
|
||||
const initializeIndexes = async () => {
|
||||
try {
|
||||
// Initialize notes index
|
||||
if (!await indexExists(NOTE_INDEX)) {
|
||||
if (!(await indexExists(NOTE_INDEX))) {
|
||||
await fetch(`${MEILISEARCH_ENDPOINT}/indexes`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -854,7 +843,7 @@ const Index = () => {
|
||||
});
|
||||
|
||||
// Initialize scratch index
|
||||
if (!await indexExists(SCRATCH_INDEX)) {
|
||||
if (!(await indexExists(SCRATCH_INDEX))) {
|
||||
await fetch(`${MEILISEARCH_ENDPOINT}/indexes`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -888,7 +877,7 @@ const Index = () => {
|
||||
});
|
||||
|
||||
// Initialize settings index
|
||||
if (!await indexExists(SETTINGS_INDEX)) {
|
||||
if (!(await indexExists(SETTINGS_INDEX))) {
|
||||
await fetch(`${MEILISEARCH_ENDPOINT}/indexes`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -1095,7 +1084,6 @@ const Index = () => {
|
||||
setCurrentNote(e.target.value);
|
||||
}}
|
||||
onBlur={handleCurrentNoteBlur}
|
||||
autoFocus
|
||||
className={`h-[calc(100%-2rem)] border-0 resize-none focus:ring-0 text-slate-200 bg-transparent ${getTextClass('2xl')}`}
|
||||
placeholder="Start writing your thoughts..."
|
||||
/>
|
||||
|
Reference in New Issue
Block a user