fa549a370b
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.
22 lines
453 B
JavaScript
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
|
|
}
|
|
}
|