diff --git a/app/views/admin/products_v3/index.html.haml b/app/views/admin/products_v3/index.html.haml index 48a43e8502..4200cd0176 100644 --- a/app/views/admin/products_v3/index.html.haml +++ b/app/views/admin/products_v3/index.html.haml @@ -1,7 +1,7 @@ - content_for :page_title do = t('.header.title') - content_for :page_actions do - %div{ :class => "toolbar", 'data-turbo': true } + %div{ :class => "toolbar" } %ul{ :class => "actions header-action-links inline-menu" } %li#new_product_link = button_link_to t(:new_product), "/admin/products/new", { :icon => 'icon-plus', :id => 'admin_new_product' } diff --git a/app/webpacker/controllers/bulk_form_controller.js b/app/webpacker/controllers/bulk_form_controller.js index 31000ca9e5..602f7c0127 100644 --- a/app/webpacker/controllers/bulk_form_controller.js +++ b/app/webpacker/controllers/bulk_form_controller.js @@ -33,25 +33,12 @@ export default class BulkFormController extends Controller { this.form.addEventListener("submit", this.#registerSubmit.bind(this)); window.addEventListener("beforeunload", this.preventLeavingChangedForm.bind(this)); - document.addEventListener("turbo:before-visit", this.preventLeavingChangedForm.bind(this)); - - // Frustratingly there's no before-frame-visit, and no other events work, so we need to bind to - // the frame and listen for any link clicks (maybe other things too). - this.turboFrame = this.form.closest("turbo-frame"); - if(this.turboFrame){ - this.turboFrame.addEventListener("click", this.preventLeavingChangedForm.bind(this)) - } } disconnect() { // Make sure to clean up anything that happened outside this.#disableOtherElements(false); window.removeEventListener("beforeunload", this.preventLeavingChangedForm.bind(this)); - document.removeEventListener("turbo:before-visit", this.preventLeavingChangedForm.bind(this)); - - if(this.turboFrame){ - this.turboFrame.removeEventListener("click", this.preventLeavingChangedForm.bind(this)); - } } // Register any new elements (may be called by another controller after dynamically adding fields) @@ -92,21 +79,9 @@ export default class BulkFormController extends Controller { } } - // If navigating away from form, warn to prevent accidental data loss + // If form is not being submitted, warn to prevent accidental data loss preventLeavingChangedForm(event) { - const target = event.target; - // Ignore non-navigation events (see above) - if(this.turboFrame && this.turboFrame.contains(target) && (target.tagName != "A" || target.dataset.turboFrame != "_self")){ - return; - } - if (this.formChanged && !this.submitting) { - // If fired by a custom event (eg Turbo), we need to explicitly ask. - // This is skipped on beforeunload. - if(confirm(I18n.t("are_you_sure"))){ - return; - } - // Cancel the event event.preventDefault(); // Chrome requires returnValue to be set, but ignores the value. Other browsers may display