Sha256: 3c5fd15807413280d2c0242f8765e074515a7220eff1589bb6984e558817add7

Contents?: true

Size: 394 Bytes

Versions: 7

Compression:

Stored size: 394 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

7 entries across 7 versions & 1 rubygems

Version Path
css-zero-0.0.44 lib/generators/css_zero/add/templates/app/javascript/controllers/hotkey_controller.js
css-zero-0.0.43 lib/generators/css_zero/add/templates/app/javascript/controllers/hotkey_controller.js
css-zero-0.0.42 lib/generators/css_zero/add/templates/app/javascript/controllers/hotkey_controller.js
css-zero-0.0.41 lib/generators/css_zero/add/templates/app/javascript/controllers/hotkey_controller.js
css-zero-0.0.40 lib/generators/css_zero/add/templates/app/javascript/controllers/hotkey_controller.js
css-zero-0.0.39 lib/generators/css_zero/add/templates/app/javascript/controllers/hotkey_controller.js
css-zero-0.0.38 lib/generators/css_zero/add/templates/app/javascript/controllers/hotkey_controller.js