MCPcopy Create free account
hub / github.com/arktypeio/arktype / onRowKey

Function onRowKey

ark/docs/components/home/BenchmarkControls.tsx:117–140  ·  view source on GitHub ↗
(e: globalThis.KeyboardEvent)

Source from the content-addressed store, hash-verified

115 }
116 /** a set's rows are one tab stop; the arrow keys, Home and End move within it */
117 const onRowKey = (e: globalThis.KeyboardEvent) => {
118 const row =
119 (
120 e.target instanceof HTMLElement &&
121 e.target.matches(".b-row[data-tip]")
122 ) ?
123 e.target
124 : null
125 const grid = row?.closest(".b-grid")
126 if (!row || !grid) return
127 const rows = [...grid.querySelectorAll<HTMLElement>(".b-row[data-tip]")]
128 const i = rows.indexOf(row)
129 const next =
130 e.key === "ArrowDown" || e.key === "ArrowRight" ? rows[i + 1]
131 : e.key === "ArrowUp" || e.key === "ArrowLeft" ? rows[i - 1]
132 : e.key === "Home" ? rows[0]
133 : e.key === "End" ? rows.at(-1)
134 : undefined
135 if (!next) return
136 e.preventDefault()
137 row.tabIndex = -1
138 next.tabIndex = 0
139 next.focus()
140 }
141 chart.addEventListener("pointerover", onTarget)
142 chart.addEventListener("focusin", onTarget)
143 chart.addEventListener("pointerleave", hide)

Callers

nothing calls this directly

Calls 2

matchesMethod · 0.80
atMethod · 0.45

Tested by

no test coverage detected