Skip to content

Commit

Permalink
Make sure mouse clicks blur other focused element even if editor isn'…
Browse files Browse the repository at this point in the history
…t focusable

FIX: Make sure that clicking an unfocusable editor still remove focus from any other
focused elements.

See https://discuss.codemirror.net/t/weird-selection-issues-in-firefox-with-multiple-editors/8197
  • Loading branch information
marijnh committed May 5, 2024
1 parent 5d4d490 commit 92bfe35
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,11 @@ handlers.mousedown = (view, event: MouseEvent) => {
if (style) {
let mustFocus = !view.hasFocus
view.inputState.startMouseSelection(new MouseSelection(view, event, style, mustFocus))
if (mustFocus) view.observer.ignore(() => focusPreventScroll(view.contentDOM))
if (mustFocus) view.observer.ignore(() => {
focusPreventScroll(view.contentDOM)
let active = view.root.activeElement
if (active && !active.contains(view.contentDOM)) (active as HTMLElement).blur()
})
let mouseSel = view.inputState.mouseSelection
if (mouseSel) {
mouseSel.start(event)
Expand Down

0 comments on commit 92bfe35

Please sign in to comment.