fix(workspace): focus a jump target only once, not again after every new block
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m40s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m40s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3e4eb9b14f
commit
20b907078f
5 files changed
+19
-7
No files matched your search
@@ -181,8 +181,14 @@ export const OutlinerTree = forwardRef<OutlinerTreeHandle, OutlinerTreeProps>(({
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Jump target (e.g. from a task): focused once, as soon as its block is loaded. Running again on later
|
||||
// block changes would pull the cursor back to it after every Enter in the note.
|
||||
const focusedTargetRef = useRef<string | null>(null);
|
||||
const targetLoaded = !!initialFocusedBlockId && blocks.some((b) => b.id === initialFocusedBlockId);
|
||||
useEffect(() => {
|
||||
if (initialFocusedBlockId) {
|
||||
if (!initialFocusedBlockId) focusedTargetRef.current = null;
|
||||
if (initialFocusedBlockId && targetLoaded && focusedTargetRef.current !== initialFocusedBlockId) {
|
||||
focusedTargetRef.current = initialFocusedBlockId;
|
||||
setHighlightedBlockId(initialFocusedBlockId);
|
||||
focusBlockInput(initialFocusedBlockId, 'select');
|
||||
const timer = setTimeout(() => {
|
||||
@@ -200,7 +206,7 @@ export const OutlinerTree = forwardRef<OutlinerTreeHandle, OutlinerTreeProps>(({
|
||||
clearTimeout(fadeTimer);
|
||||
};
|
||||
}
|
||||
}, [initialFocusedBlockId, blocks.length, focusBlockInput]);
|
||||
}, [initialFocusedBlockId, targetLoaded, focusBlockInput]);
|
||||
|
||||
// Compute visibility based on collapsed ancestor blocks
|
||||
const visibleEntries = useMemo(() => {
|
||||
|
||||
Reference in new issue
Block a user