MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / dispatchClick

Function dispatchClick

source code/ink/hit-test.ts:51–91  ·  view source on GitHub ↗
(
  root: DOMElement,
  col: number,
  row: number,
  cellIsBlank = false,
)

Source from the content-addressed store, hash-verified

49 * true if at least one onClick handler fired.
50 */
51export function dispatchClick(
52 root: DOMElement,
53 col: number,
54 row: number,
55 cellIsBlank = false,
56): boolean {
57 let target: DOMElement | undefined = hitTest(root, col, row) ?? undefined
58 if (!target) return false
59
60 // Click-to-focus: find the closest focusable ancestor and focus it.
61 // root is always ink-root, which owns the FocusManager.
62 if (root.focusManager) {
63 let focusTarget: DOMElement | undefined = target
64 while (focusTarget) {
65 if (typeof focusTarget.attributes['tabIndex'] === 'number') {
66 root.focusManager.handleClickFocus(focusTarget)
67 break
68 }
69 focusTarget = focusTarget.parentNode
70 }
71 }
72 const event = new ClickEvent(col, row, cellIsBlank)
73 let handled = false
74 while (target) {
75 const handler = target._eventHandlers?.onClick as
76 | ((event: ClickEvent) => void)
77 | undefined
78 if (handler) {
79 handled = true
80 const rect = nodeCache.get(target)
81 if (rect) {
82 event.localCol = col - rect.x
83 event.localRow = row - rect.y
84 }
85 handler(event)
86 if (event.didStopImmediatePropagation()) return true
87 }
88 target = target.parentNode
89 }
90 return handled
91}
92
93/**
94 * Fire onMouseEnter/onMouseLeave as the pointer moves. Like DOM

Callers 1

dispatchClickMethod · 0.85

Calls 4

hitTestFunction · 0.85
handleClickFocusMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected