Skip to content

Commit acba2e0

Browse files
committed
Prevent clicking the completion scrollbar from moving focus
FIX: Fix an issue where clicking on the scrollbar for the completion list could move focus out of the editor. See https://discuss.codemirror.net/t/autocomplete-closes-on-scrollbar-click/9017
1 parent 007c238 commit acba2e0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/tooltip.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ class CompletionTooltip {
247247
ul.setAttribute("role", "listbox")
248248
ul.setAttribute("aria-expanded", "true")
249249
ul.setAttribute("aria-label", this.view.state.phrase("Completions"))
250+
ul.addEventListener("mousedown", e => {
251+
// Prevent focus change when clicking the scrollbar
252+
if (e.target == ul) e.preventDefault()
253+
})
250254
let curSection: string | null = null
251255
for (let i = range.from; i < range.to; i++) {
252256
let {completion, match} = options[i], {section} = completion

0 commit comments

Comments
 (0)