Sha256: 83bff2a0f69618de11755c864be368f31028f36ebc594e728b9892814c181352

Contents?: true

Size: 408 Bytes

Versions: 2

Compression:

Stored size: 408 Bytes

Contents

import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
  click(event) {
    if (this.#isClickable && !this.#shouldIgnore(event)) {
      this.element.click()
    }
  }

  #shouldIgnore(event) {
    return event.defaultPrevented || event.target.closest("input, textarea")
  }

  get #isClickable() {
    return getComputedStyle(this.element).pointerEvents !== "none"
  }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
css-zero-0.0.37 lib/generators/css_zero/add/templates/app/javascript/controllers/hotkey_controller.js
css-zero-0.0.36 lib/generators/css_zero/add/templates/app/javascript/controllers/hotkey_controller.js