Skip to content

Commit 7291798

Browse files
Focus title
1 parent 6f1e0fa commit 7291798

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/components/List.svelte

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@
6464
}
6565
}
6666
67+
function focusZoomedTitle() {
68+
requestAnimationFrame(() => {
69+
const titleEditor = containerElement?.querySelector('.zoomed_title [contenteditable]')
70+
if (titleEditor) {
71+
titleEditor.focus()
72+
const range = document.createRange()
73+
const sel = window.getSelection()
74+
range.selectNodeContents(titleEditor)
75+
range.collapse(false)
76+
sel.removeAllRanges()
77+
sel.addRange(range)
78+
}
79+
})
80+
}
81+
6782
function handleSelectUp(event) {
6883
const id = event.detail.id
6984
const items = get(itemStore.items)
@@ -72,6 +87,8 @@
7287
if (prevItem) {
7388
itemStore.clearSelection()
7489
focusItem(prevItem.id)
90+
} else if (isZoomedRoot) {
91+
focusZoomedTitle()
7592
} else {
7693
dispatch('focusparent')
7794
}

0 commit comments

Comments
 (0)