Move dialog focus handling to a stimulus controller

... for template caching
This commit is contained in:
Adrien Maston
2026-01-12 17:30:16 +01:00
parent 82d4fa5214
commit 3d092583eb
9 changed files with 32 additions and 16 deletions
@@ -0,0 +1,16 @@
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
}
}