diff --git a/app/views/spree/admin/images/edit.turbo_stream.haml b/app/views/spree/admin/images/edit.turbo_stream.haml index 89dbb89bdfe..d2ffe7dd534 100644 --- a/app/views/spree/admin/images/edit.turbo_stream.haml +++ b/app/views/spree/admin/images/edit.turbo_stream.haml @@ -5,9 +5,10 @@ -# Display image in the same way it appears in the shopfront popup %p= image_tag @image.persisted? ? @image.url(:large) : Spree::Image.default_image_url(:large), width: 433, height: 433 - -# Submit as turbo stream to avoid full page reload. But turbo is ignoring it??!! + -# Submit as turbo stream to avoid full page reload. + -# TODO: show loading indicator. = form_for [:admin, @product, @image], - html: { multipart: true }, data: { controller: "form", 'turbo-stream': true } do |f| + html: { multipart: true }, data: { controller: "form" } do |f| %input{ type: :hidden, name: :return_url, value: request.referer } = f.hidden_field :viewable_id, value: @product.id diff --git a/app/webpacker/controllers/form_controller.js b/app/webpacker/controllers/form_controller.js index aaac9db4ecf..54354d340f5 100644 --- a/app/webpacker/controllers/form_controller.js +++ b/app/webpacker/controllers/form_controller.js @@ -2,6 +2,8 @@ import { Controller } from "stimulus"; export default class FormController extends Controller { submit() { - this.element.submit(); + // Validate and submit the form, using the default submit button. Raises JS events. + // Ref: https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/requestSubmit + this.element.requestSubmit(); } }