Files
fizzy/app/javascript/controllers/dialog_focus_controller.js
T
Adrien Maston 3d092583eb Move dialog focus handling to a stimulus controller
... for template caching
2026-01-12 17:30:16 +01:00

17 lines
408 B
JavaScript

import { Controller } from "@hotwired/stimulus"
import { isTouchDevice } from "helpers/platform_helpers"
export default class extends Controller {
static targets = [ "mouse", "touch" ]
connect() {
this.#setup()
}
#setup() {
const touch = isTouchDevice()
if (this.hasMouseTarget) this.mouseTarget.autofocus = !touch
if (this.hasTouchTarget) this.touchTarget.autofocus = touch
}
}