Skip to content

Commit c8f7752

Browse files
committed
focus previous element instead of editor
when mouse leaves inline result
1 parent 753fa98 commit c8f7752

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/editor/result-view.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,19 @@ export default class ResultView {
8383
if (ev.button === 1) {
8484
// middle mouse button
8585
this.model.remove()
86-
this.focusEditor()
86+
this.focusPrevious()
8787
} else if (document.getSelection().toString().length === 0) {
88-
this.focusEditor()
88+
this.focusPrevious()
8989
}
9090
})
9191

9292
this.view.addEventListener('mousedown', ev => {
9393
this.blurEditor()
94+
this.previousFocus = document.activeElement
9495
})
9596

9697
this.view.addEventListener('mouseleave', ev => {
97-
this.focusEditor()
98+
this.focusPrevious()
9899
})
99100

100101
if (fade) this.fadeIn()
@@ -113,10 +114,9 @@ export default class ResultView {
113114
}
114115
}
115116

116-
focusEditor () {
117-
const c = this.model.editor.component
118-
if (c && c.didFocus) {
119-
c.didFocus()
117+
focusPrevious () {
118+
if (this.previousFocus) {
119+
this.previousFocus.focus()
120120
}
121121
}
122122

0 commit comments

Comments
 (0)