diff --git a/app/javascript/controllers/commands_controller.js b/app/javascript/controllers/commands_controller.js index 71560576b..ad72fdac0 100644 --- a/app/javascript/controllers/commands_controller.js +++ b/app/javascript/controllers/commands_controller.js @@ -4,4 +4,9 @@ export default class extends Controller { static targets = [ "input" ] // Actions + + focus() { + console.debug("CALLED!"); + this.inputTarget.focus() + } } diff --git a/app/views/commands/_form.html.erb b/app/views/commands/_form.html.erb index 77a452ab2..58542a03e 100644 --- a/app/views/commands/_form.html.erb +++ b/app/views/commands/_form.html.erb @@ -3,14 +3,13 @@ <%= form_tag commands_path, id: "commands_form", class: [ "flex align-center gap-half", { "has-error" => has_error } ], - data: { controller: "form", action: "turbo:submit-end->form#reset" } do %> + data: { controller: "form", action: "turbo:submit-end->form#reset turbo:submit-end->commands#focus", turbo_permanent: true } do %> <%= text_field_tag "command", has_error ? params[:command] : nil, autocomplete: "off", autocorrect: "off", autocapitalize: "off", - autofocus: has_error, class: "terminal__input input fill-transparent unpad", data: { commands_target: "input",