Stopped upgrade form from submitting on enter

This commit is contained in:
Kieran Eglin 2024-04-16 17:03:43 -07:00
parent b38b10ba83
commit 32d29b0209
No known key found for this signature in database
GPG key ID: 193984967FCF432D
2 changed files with 13 additions and 1 deletions

View file

@ -36,6 +36,17 @@ let liveSocket = new LiveSocket('/live', Socket, {
window.Alpine.clone(from, to)
}
}
},
hooks: {
supressEnterSubmission: {
mounted() {
this.el.addEventListener('keypress', (event) => {
if (event.key === 'Enter') {
event.preventDefault()
}
})
}
}
}
})

View file

@ -3,10 +3,11 @@ defmodule Pinchflat.UpgradeButtonLive do
def render(assigns) do
~H"""
<form phx-change="check_matching_text">
<form id="upgradeForm" phx-change="check_matching_text" phx-hook="supressEnterSubmission">
<.input type="text" name="unlock-pro-textbox" value="" />
</form>
<%!-- The setTimeout is so the modal has time to disappear before it's removed --%>
<.button
class="w-full mt-4"
type="button"