Sha256: f826454813275ececa2c951c97659561e0827eab7a6919d42333df92b01abba8
Contents?: true
Size: 844 Bytes
Versions: 1
Compression:
Stored size: 844 Bytes
Contents
import { Controller } from "@hotwired/stimulus" export default class extends Controller { static targets = [ "item" ] static values = { index: Number } indexValueChanged() { this.#removeTabstops() } prev() { const hasPrevious = this.indexValue > 0 hasPrevious && this.indexValue-- hasPrevious && this.#focusCurrentItem() } next() { const hasNext = this.indexValue < this.#lastIndex hasNext && this.indexValue++ hasNext && this.#focusCurrentItem() } reset() { this.indexValue = 0 this.#focusCurrentItem() } #removeTabstops() { this.itemTargets.forEach(item => item.tabIndex = -1) } #focusCurrentItem() { this.itemTargets[this.indexValue].tabIndex = 0 this.itemTargets[this.indexValue].focus() } get #lastIndex() { return this.itemTargets.length -1 } }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
css-zero-0.0.47 | lib/generators/css_zero/add/templates/app/javascript/controllers/menu_controller.js |