Introduce a simple stimulus controller for the magic link form
which avoids the double-submit problem from: - https://app.fizzy.do/5986089/cards/2980 - https://app.fizzy.do/5986089/cards/2771
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
import { onNextEventLoopTick } from "helpers/timing_helpers"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = [ "input" ]
|
||||
|
||||
submit(event) {
|
||||
onNextEventLoopTick(() => {
|
||||
this.inputTarget.disabled = true
|
||||
})
|
||||
}
|
||||
|
||||
paste(event) {
|
||||
onNextEventLoopTick(() => {
|
||||
this.element.submit()
|
||||
this.inputTarget.disabled = true
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user