Fix scroll position when typing in long notes
- Preserve textarea scroll position during auto-resize in onChange handler - Prevents view from jumping to top when typing below the fold
This commit is contained in:
@@ -861,9 +861,11 @@ export function NoteEditor({ note, onUpdateNote, onUnsavedChanges, categories, i
|
|||||||
value={localContent}
|
value={localContent}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
handleContentChange(e.target.value);
|
handleContentChange(e.target.value);
|
||||||
// Auto-resize textarea to fit content
|
// Auto-resize textarea to fit content while preserving scroll position
|
||||||
|
const scrollTop = e.target.scrollTop;
|
||||||
e.target.style.height = 'auto';
|
e.target.style.height = 'auto';
|
||||||
e.target.style.height = e.target.scrollHeight + 'px';
|
e.target.style.height = e.target.scrollHeight + 'px';
|
||||||
|
e.target.scrollTop = scrollTop;
|
||||||
}}
|
}}
|
||||||
className="w-full resize-none border-none outline-none focus:ring-0 bg-transparent text-gray-900 dark:text-gray-100 overflow-hidden"
|
className="w-full resize-none border-none outline-none focus:ring-0 bg-transparent text-gray-900 dark:text-gray-100 overflow-hidden"
|
||||||
style={{ fontSize: `${editorFontSize}px`, lineHeight: '1.6', minHeight: '100%', fontFamily: editorFont }}
|
style={{ fontSize: `${editorFontSize}px`, lineHeight: '1.6', minHeight: '100%', fontFamily: editorFont }}
|
||||||
|
|||||||
Reference in New Issue
Block a user