Move dialog focus handling to a stimulus controller
... for template caching
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user