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

Function findTarget

packages/app-core/src/components/Sidebar.tsx:2580–2679  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2578 if (!isSidebarFocused) return;
2579
2580 const findTarget = (): HTMLElement | null => {
2581 if (
2582 isRecentSidebarPointerInteraction(
2583 lastSidebarPointerAtRef.current,
2584 performance.now(),
2585 )
2586 ) {
2587 const cursorEl = document.querySelector<HTMLElement>(
2588 `[data-sidebar-idx="${sidebarCursorIndex}"]`,
2589 );
2590 if (cursorEl) return cursorEl;
2591 }
2592
2593 if (tagsViewActive && selectedTags.length > 0) {
2594 // When the Tags view is active, reveal the first currently-
2595 // selected tag's chip. The user can hop between them with j/k
2596 // from there once this scroll brings it into view.
2597 return document.querySelector(
2598 `[data-sidebar-type="tag"][data-sidebar-tag="${escapeForAttr(selectedTags[0])}"]`,
2599 ) as HTMLElement | null;
2600 }
2601
2602 if (trashViewActive) {
2603 return document.querySelector(
2604 '[data-sidebar-type="trash"]',
2605 ) as HTMLElement | null;
2606 }
2607
2608 if (archiveViewActive) {
2609 return document.querySelector(
2610 '[data-sidebar-type="archive"]',
2611 ) as HTMLElement | null;
2612 }
2613
2614 if (quickNotesViewActive) {
2615 return document.querySelector(
2616 '[data-sidebar-type="folder"][data-sidebar-folder="quick"][data-sidebar-subpath=""]',
2617 ) as HTMLElement | null;
2618 }
2619
2620 if (selectedPath) {
2621 if (
2622 isArchiveTabPath(selectedPath) ||
2623 selectedPath.startsWith("archive/")
2624 ) {
2625 return document.querySelector(
2626 '[data-sidebar-type="archive"]',
2627 ) as HTMLElement | null;
2628 }
2629 if (isTrashTabPath(selectedPath) || selectedPath.startsWith("trash/")) {
2630 return document.querySelector(
2631 '[data-sidebar-type="trash"]',
2632 ) as HTMLElement | null;
2633 }
2634 }
2635
2636 if (selectedPath && unifiedSidebar) {
2637 if (isQuickNotesTabPath(selectedPath)) {

Callers 1

SidebarFunction · 0.85

Calls 6

isArchiveTabPathFunction · 0.90
isTrashTabPathFunction · 0.90
isQuickNotesTabPathFunction · 0.90
noteFolderSubpathFunction · 0.90
escapeForAttrFunction · 0.70

Tested by

no test coverage detected