Skip to content

Commit e5beebf

Browse files
committedSep 19, 2023
fix: select active element on undo only when existing
1 parent d4e301f commit e5beebf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎src/lib/components/modes/treemode/TreeMode.svelte

+4-4
Original file line numberDiff line numberDiff line change
@@ -1783,11 +1783,11 @@
17831783
// TODO: find a better way to restore focus
17841784
// TODO: implement a proper TypeScript solution to check whether this is an element with blur, focus, select
17851785
const activeElement = document.activeElement as HTMLInputElement
1786-
if (activeElement && activeElement.blur && activeElement.focus) {
1786+
if (activeElement && activeElement.blur && activeElement.select) {
17871787
activeElement.blur()
17881788
setTimeout(() => {
17891789
handleUndo()
1790-
setTimeout(() => activeElement.select())
1790+
setTimeout(() => activeElement?.select())
17911791
})
17921792
} else {
17931793
handleUndo()
@@ -1800,11 +1800,11 @@
18001800
// TODO: find a better way to restore focus
18011801
// TODO: implement a proper TypeScript solution to check whether this is an element with blur, focus, select
18021802
const activeElement = document.activeElement as HTMLInputElement
1803-
if (activeElement && activeElement.blur && activeElement.focus) {
1803+
if (activeElement && activeElement.blur && activeElement.select) {
18041804
activeElement.blur()
18051805
setTimeout(() => {
18061806
handleRedo()
1807-
setTimeout(() => activeElement.select())
1807+
setTimeout(() => activeElement?.select())
18081808
})
18091809
} else {
18101810
handleRedo()

0 commit comments

Comments
 (0)
Please sign in to comment.