MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / focusPaneInDirection

Function focusPaneInDirection

packages/app-core/src/lib/pane-nav.ts:154–177  ·  view source on GitHub ↗
(direction: PaneDirection)

Source from the content-addressed store, hash-verified

152 * focused so keyboard input lands in the new pane's CodeMirror view.
153 */
154export function focusPaneInDirection(direction: PaneDirection): boolean {
155 const state = useStore.getState()
156 const rects = getPaneRects()
157 // Treat the pinned reference pane as the "currently focused" pane
158 // when its CodeMirror is the active element — geometric nav picks up
159 // from where the cursor actually lives, not from activePaneId.
160 const activeEl = document.activeElement as HTMLElement | null
161 const inPinned =
162 activeEl?.closest(`[data-pane-id="${PINNED_REF_PANE_ID}"]`) != null
163 const currentId = inPinned ? PINNED_REF_PANE_ID : state.activePaneId
164 const targetId = findNeighborPaneId(rects, currentId, direction)
165 if (!targetId) return false
166 if (targetId === PINNED_REF_PANE_ID) {
167 state.setFocusedPanel('editor')
168 requestAnimationFrame(focusPinnedRefDom)
169 return true
170 }
171 state.setActivePane(targetId)
172 state.setFocusedPanel('editor')
173 requestAnimationFrame(() => {
174 useStore.getState().editorViewRef?.focus()
175 })
176 return true
177}
178
179/** Focus the editor pane at the left or right edge of the editor area. Used
180 * when crossing in from an edge panel (sidebar / note list / connections) so

Callers 4

focusDirFunction · 0.90
handlerFunction · 0.90
buildCommandsFunction · 0.90
focusPaneOrEdgePanelFunction · 0.85

Calls 2

getPaneRectsFunction · 0.85
findNeighborPaneIdFunction · 0.85

Tested by

no test coverage detected