Skip to content

Commit

Permalink
rootedGrandparentOf instead of 2x rootedParentOf
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-james committed Jan 17, 2025
1 parent 76f038a commit 650b1f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/LayoutTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import getStyle from '../selectors/getStyle'
import getThoughtById from '../selectors/getThoughtById'
import isContextViewActive from '../selectors/isContextViewActive'
import nextSibling from '../selectors/nextSibling'
import rootedParentOf from '../selectors/rootedParentOf'
import rootedParentOf, { rootedGrandparentOf } from '../selectors/rootedParentOf'
import simplifyPath from '../selectors/simplifyPath'
import thoughtToPath from '../selectors/thoughtToPath'
import reactMinistore from '../stores/react-ministore'
Expand Down Expand Up @@ -912,7 +912,7 @@ const LayoutTree = () => {
// When the cursor is in a table, all thoughts beneath the table are hidden,
// so there is no concern about animation name conflicts with subsequent (deeper) thoughts.
const tableDepth = useSelector(state =>
state.cursor && attributeEquals(state, head(rootedParentOf(state, state.cursor)), '=view', 'Table') ? 1 : 0,
state.cursor && attributeEquals(state, head(rootedGrandparentOf(state, state.cursor)), '=view', 'Table') ? 1 : 0,
)
// The indentDepth multipicand (0.9) causes the horizontal counter-indentation to fall short of the actual indentation, causing a progressive shifting right as the user navigates deeper. This provides an additional cue for the user's depth, which is helpful when autofocus obscures the actual depth, but it must stay small otherwise the thought width becomes too small.
// The indentCursorAncestorTables multipicand (0.5) is smaller, since animating over by the entire width of column 1 is too abrupt.
Expand Down
4 changes: 4 additions & 0 deletions src/selectors/rootedParentOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ const rootedParentOf = <T extends Context | Path>(state: State, thoughts: T): T
: (state.rootContext as T)
}

/** Calls rootedParentOf twice to get the rooted grandparent of a thought. */
export const rootedGrandparentOf = <T extends Context | Path>(state: State, thoughts: T): T =>
rootedParentOf(state, rootedParentOf(state, thoughts))

export default rootedParentOf

0 comments on commit 650b1f0

Please sign in to comment.