Allow typing magic links on mobile
When typing a magic link, rather than pasting it, iOS seems to send `keydown.enter`, and we weren't submitting the form in that case. Changed to submit the form in either case, and use the state of the input target to help guard against double submissions.
This commit is contained in:
@@ -4,16 +4,12 @@ import { onNextEventLoopTick } from "helpers/timing_helpers"
|
||||
export default class extends Controller {
|
||||
static targets = [ "input" ]
|
||||
|
||||
submit(event) {
|
||||
submit() {
|
||||
onNextEventLoopTick(() => {
|
||||
this.inputTarget.disabled = true
|
||||
})
|
||||
}
|
||||
|
||||
paste(event) {
|
||||
onNextEventLoopTick(() => {
|
||||
this.element.submit()
|
||||
this.inputTarget.disabled = true
|
||||
if (!this.inputTarget.disabled) {
|
||||
this.element.submit()
|
||||
this.inputTarget.disabled = true
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user