diff --git a/app/javascript/controllers/form_validation_controller.js b/app/javascript/controllers/form_validation_controller.js index 8756e272..dd1a98ed 100644 --- a/app/javascript/controllers/form_validation_controller.js +++ b/app/javascript/controllers/form_validation_controller.js @@ -28,12 +28,16 @@ export default class extends Controller { } submit(event = undefined) { + if (this.submitting) return; + + this.submitting = true; + event?.preventDefault(); if (this.element.reportValidity()) { this.element.classList.remove("was-validated"); - if (this.element.getAttributeNames().some(x => x.startsWith("hx-"))) this.element.submit(); + if (!this.element.getAttributeNames().some(x => x.startsWith("hx-"))) this.element.submit(); window.dispatchEvent(new CustomEvent("notification:show", { detail: { id: this.submittingIdValue } })); } else { @@ -43,5 +47,7 @@ export default class extends Controller { window.dispatchEvent(new CustomEvent("notification:show", { detail: { id: this.invalidIdValue } })); } + + this.submitting = false; } } diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index dc87b1c3..a0f18024 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -41,5 +41,5 @@ Rails.start() Turbolinks.start() ActiveStorage.start() -window.htmx = require("@suttyweb/htmx.org/dist/htmx.js"); +window.htmx = require("@suttyweb/htmx.org/dist/htmx.cjs.js"); window.htmx.config.selfRequestsOnly = true; diff --git a/package.json b/package.json index 73cfd589..c5642236 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "@rails/ujs": "^6.1.3-1", "@rails/webpacker": "5.4.4", "@suttyweb/editor": "^0.1.29", - "@suttyweb/htmx.org": "^1.9.13", + "@suttyweb/htmx.org": "2.0.0", "babel-loader": "^8.2.2", "bs-custom-file-input": "^1.3.4", "chart.js": "^3.5.1", diff --git a/yarn.lock b/yarn.lock index d181bebe..45ceae0a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1984,10 +1984,10 @@ linkifyjs "^4.1.1" prosemirror-svelte-nodeview "^1.0.2" -"@suttyweb/htmx.org@^1.9.13": - version "1.9.13" - resolved "https://registry.yarnpkg.com/@suttyweb/htmx.org/-/htmx.org-1.9.13.tgz#bc67a5e2947d7cc125649b829610da8ee61f21af" - integrity sha512-/2x3AGXT2CFOmp8Nf59XY2brah5wSo4YvcctYA2zD4BByNft4XE0rUk4VM7TjPxR1LOzg6VK1crZmdiy3JyzxQ== +"@suttyweb/htmx.org@2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@suttyweb/htmx.org/-/htmx.org-2.0.0.tgz#44435d834d143ae9b60daa454f68f8e72e6ebd7f" + integrity sha512-EJk9s8judGLIZ6c9N779z91WHPIfAkwkVY5QF7WH2ZT2Kt03k/hAoy7P4NjYreFIQcIo8d+TU/CIhViCmB4c0Q== "@types/caseless@*": version "0.12.2"