Reset form automatically

This commit is contained in:
Jorge Manrubia
2025-05-06 09:30:37 +02:00
parent 3954033e61
commit 456463ffef
2 changed files with 7 additions and 1 deletions
@@ -19,6 +19,11 @@ export default class extends Controller {
event.target.select()
}
reset(event) {
console.debug("CALLED!");
this.element.reset()
}
showPicker(event) {
if ("showPicker" in HTMLInputElement.prototype) {
event.target.showPicker()
+2 -1
View File
@@ -5,7 +5,7 @@
<%= form_tag commands_path,
class: "flex align-center gap-half",
data: { controller: "form" } do %>
data: { controller: "form", action: "turbo:submit-end->form#reset" } do %>
<label class="terminal__label txt-nowrap" for="fizzy_do">Fizzy do &gt;</label>
<%= text_field_tag "command", nil,
@@ -14,6 +14,7 @@
autocapitalize: "off",
class: "terminal__input input fill-transparent unpad",
data: {
turbo_permanent: true,
commands_target: "input",
action: "keydown.up->toggle-class#add:prevent keydown.down->toggle-class#remove:prevent"
},