Skip to content

Commit

Permalink
setCursor: Clear browser selection when a divider is selected. Fixes #…
Browse files Browse the repository at this point in the history
…342 again.
  • Loading branch information
raineorshine committed Jul 2, 2020
1 parent 2b4891a commit b30b29b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/reducers/setCursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { store } from '../store'
import { dataIntegrityCheck, loadResource } from '../action-creators'
import { TUTORIAL2_STEP_CONTEXT_VIEW_SELECT, TUTORIAL_CONTEXT, TUTORIAL_STEP_AUTOEXPAND, TUTORIAL_STEP_AUTOEXPAND_EXPAND } from '../constants'
import { chain, expandThoughts, getSetting, getThoughts, lastThoughtsFromContextChain } from '../selectors'
import { equalPath, hashContext, headValue, isDescendant, pathToContext } from '../util'
import { clearSelection, equalPath, hashContext, headValue, isDescendant, isDivider, pathToContext } from '../util'
import { render, settings } from '../reducers'
import { State } from '../util/initialState'
import { Child, Path, TutorialChoice } from '../types'
Expand All @@ -23,6 +23,7 @@ interface Payload {
* Sets the cursor on a thought.
* Set both cursorBeforeEdit (the transcendental head) and cursor (the live value during editing).
* The other contexts superscript uses cursor when it is available.
* Side Effects: clearSelection.
*/
const setCursor = (state: State, {
contextChain = [],
Expand All @@ -39,6 +40,12 @@ const setCursor = (state: State, {
? chain(state, contextChain, thoughtsRanked)
: thoughtsRanked

// SIDE EFFECT
// clear the browser selection if a divider is being selected
if (thoughtsResolved && isDivider(headValue(thoughtsResolved))) {
clearSelection()
}

// sync replaceContextViews with state.contextViews
// ignore thoughts that are not in the path of replaceContextViews
// shallow copy
Expand Down

0 comments on commit b30b29b

Please sign in to comment.