Skip to content

Commit

Permalink
fix: select active element on undo only when existing
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Sep 19, 2023
1 parent d4e301f commit e5beebf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib/components/modes/treemode/TreeMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -1783,11 +1783,11 @@
// TODO: find a better way to restore focus
// TODO: implement a proper TypeScript solution to check whether this is an element with blur, focus, select
const activeElement = document.activeElement as HTMLInputElement
if (activeElement && activeElement.blur && activeElement.focus) {
if (activeElement && activeElement.blur && activeElement.select) {
activeElement.blur()
setTimeout(() => {
handleUndo()
setTimeout(() => activeElement.select())
setTimeout(() => activeElement?.select())
})
} else {
handleUndo()
Expand All @@ -1800,11 +1800,11 @@
// TODO: find a better way to restore focus
// TODO: implement a proper TypeScript solution to check whether this is an element with blur, focus, select
const activeElement = document.activeElement as HTMLInputElement
if (activeElement && activeElement.blur && activeElement.focus) {
if (activeElement && activeElement.blur && activeElement.select) {
activeElement.blur()
setTimeout(() => {
handleRedo()
setTimeout(() => activeElement.select())
setTimeout(() => activeElement?.select())
})
} else {
handleRedo()
Expand Down

0 comments on commit e5beebf

Please sign in to comment.