Skip to content

Commit

Permalink
only remove existing selection if editor has focus
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Jul 29, 2022
1 parent ebd1f4d commit d49a2bd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/y-remote-selections.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ export class YRemoteSelectionsPluginValue {

// set local awareness state (update cursors)
if (localAwarenessState != null) {
const sel = update.view.hasFocus && update.view.dom.ownerDocument.hasFocus() ? update.state.selection.main : null
const hasFocus = update.view.hasFocus && update.view.dom.ownerDocument.hasFocus()
const sel = hasFocus ? update.state.selection.main : null
const currentAnchor = localAwarenessState.cursor == null ? null : Y.createRelativePositionFromJSON(localAwarenessState.cursor.anchor)
const currentHead = localAwarenessState.cursor == null ? null : Y.createRelativePositionFromJSON(localAwarenessState.cursor.head)

Expand All @@ -171,7 +172,7 @@ export class YRemoteSelectionsPluginValue {
head
})
}
} else if (localAwarenessState.cursor != null) {
} else if (localAwarenessState.cursor != null && hasFocus) {
awareness.setLocalStateField('cursor', null)
}
}
Expand Down

0 comments on commit d49a2bd

Please sign in to comment.