Files
fizzy/app/javascript/controllers/magic_link_controller.js
T
Mike Dalessio fa549a370b Add a system test for joining an account
Reworked the magic link stimulus controller, because the system test
was causing double-submission of the form (because the event was
bubbling up). I think that change simplifies the form and will still
work well for iOS devices.
2025-12-05 21:51:44 -05:00

22 lines
453 B
JavaScript

import { Controller } from "@hotwired/stimulus"
import { onNextEventLoopTick } from "helpers/timing_helpers"
export default class extends Controller {
static targets = [ "input" ]
submitOnEnter(event) {
event.preventDefault()
this.submit()
}
submitOnPaste() {
onNextEventLoopTick(() => this.submit())
}
submit() {
if (this.inputTarget.disabled) return
this.element.submit()
this.inputTarget.disabled = true
}
}