forked from MapComplete/MapComplete
chore: automated housekeeping...
This commit is contained in:
parent
c9ce29f206
commit
40e894df8b
294 changed files with 14209 additions and 4192 deletions
|
|
@ -1,10 +1,14 @@
|
|||
export function focusWithArrows(htmlElement: HTMLDivElement, classname: string) {
|
||||
const destroy: () => void = undefined
|
||||
htmlElement.addEventListener("keyup", e => {
|
||||
htmlElement.addEventListener("keyup", (e) => {
|
||||
const currentElement = document.activeElement
|
||||
const canBeSelected = <HTMLElement[]> Array.from(htmlElement.getElementsByClassName(classname))
|
||||
const canBeSelected = <HTMLElement[]>(
|
||||
Array.from(htmlElement.getElementsByClassName(classname))
|
||||
)
|
||||
|
||||
const i = canBeSelected.findIndex(el => el.contains(currentElement) || el === currentElement)
|
||||
const i = canBeSelected.findIndex(
|
||||
(el) => el.contains(currentElement) || el === currentElement
|
||||
)
|
||||
const l = canBeSelected.length
|
||||
if (e.key === "ArrowDown") {
|
||||
canBeSelected.at((i + 1) % l).focus()
|
||||
|
|
@ -12,10 +16,9 @@ export function focusWithArrows(htmlElement: HTMLDivElement, classname: string)
|
|||
}
|
||||
|
||||
if (e.key === "ArrowUp") {
|
||||
canBeSelected.at((i - 1) ).focus()
|
||||
canBeSelected.at(i - 1).focus()
|
||||
return
|
||||
}
|
||||
})
|
||||
return { destroy }
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue