Inline touch check thats only used once

Not worth loading an entire file for this.
This commit is contained in:
David Heinemeier Hansson
2025-04-20 16:21:08 +02:00
parent 883a225946
commit d3fa62d4c2
2 changed files with 2 additions and 5 deletions
@@ -1,10 +1,10 @@
import { Controller } from "@hotwired/stimulus"
import { nextEventNamed } from "helpers/timing_helpers"
import { isTouchDevice } from "helpers/navigator_helpers"
export default class extends Controller {
// Only load for touch devices
static get shouldLoad() {
return isTouchDevice()
return "ontouchstart" in window && navigator.maxTouchPoints > 0
}
// Use a fake input to trigger the soft keyboard on actions that load async content
@@ -1,3 +0,0 @@
export function isTouchDevice() {
return "ontouchstart" in window && navigator.maxTouchPoints > 0
}