fix: skip editor reload when remote content is identical
This commit is contained in:
parent
c58d13eafa
commit
8581117708
2 changed files with 9 additions and 4 deletions
|
|
@ -14,7 +14,7 @@
|
||||||
## 3. Focus and caret/scroll restore
|
## 3. Focus and caret/scroll restore
|
||||||
|
|
||||||
- [x] 3.1 In `loadNoteForTab`, after setting `editor.value`, restore caret via `setSelectionRange` with offsets clamped to content length (default 0 for legacy records), restore `scrollTop` (in `requestAnimationFrame` if layout timing clamps it), and call `editor.focus()`
|
- [x] 3.1 In `loadNoteForTab`, after setting `editor.value`, restore caret via `setSelectionRange` with offsets clamped to content length (default 0 for legacy records), restore `scrollTop` (in `requestAnimationFrame` if layout timing clamps it), and call `editor.focus()`
|
||||||
- [ ] 3.2 Make `reloadFromDB` skip the `editor.value` assignment when fetched content is identical, so remote saves never move the local caret unnecessarily
|
- [x] 3.2 Make `reloadFromDB` skip the `editor.value` assignment when fetched content is identical, so remote saves never move the local caret unnecessarily
|
||||||
- [ ] 3.3 Manually verify focus lands when the panel opens via toolbar action and via keyboard shortcut; caret restore works on panel open, tab switch, and SPA navigation
|
- [ ] 3.3 Manually verify focus lands when the panel opens via toolbar action and via keyboard shortcut; caret restore works on panel open, tab switch, and SPA navigation
|
||||||
|
|
||||||
## 4. Adjustable font size
|
## 4. Adjustable font size
|
||||||
|
|
|
||||||
|
|
@ -202,9 +202,14 @@ async function reloadFromDB() {
|
||||||
if (!currentKey) return;
|
if (!currentKey) return;
|
||||||
try {
|
try {
|
||||||
const note = await getNoteByKey(currentKey);
|
const note = await getNoteByKey(currentKey);
|
||||||
|
const content = note ? note.content : '';
|
||||||
|
// Skip the assignment when content is unchanged: setting editor.value
|
||||||
|
// would needlessly reset this panel's caret to the start.
|
||||||
|
if (content !== editor.value) {
|
||||||
isLoadingContent = true;
|
isLoadingContent = true;
|
||||||
editor.value = note ? note.content : '';
|
editor.value = content;
|
||||||
isLoadingContent = false;
|
isLoadingContent = false;
|
||||||
|
}
|
||||||
currentNote = note;
|
currentNote = note;
|
||||||
updateStatus('Saved');
|
updateStatus('Saved');
|
||||||
deferredReload = false;
|
deferredReload = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue