Does viewUpdate.selectionSet
mean the selection changed just like viewUpdate.focusChanged
means the focus changed?
If so, why not call it selectionChanged
for consistency? If not, then what is the current equivalent of a hypothetical selectionChanged
boolean that would indicate selection changed regardless if it was “explicit”? There is no ViewUpdate.selectionChanged
boolean.
Quoting the docs:
Whether the selection was explicitly set in this update.
If the document changes, the selection will often also change to move along with its new document position. But that won’t set selectionSet
to true — that only happens when the selection
property of a transaction spec was used to explicitly move the selection.
Ah, thanks. So what’s the official condition for any time the selection changes? I suppose (update.docChanged || update.selectionSet) && !equal(lastSelection, currentSelection)
?
Both transactions and view update object have an old state, so you could do tr.startState.selection.eq(tr.state.selection.eq)
or something similar to check for changes in the actual selection positions.
1 Like