From 544ead2b49ff0700b57a923231daf48796d03503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Souk=C3=A9ina=20Bojabza?= Date: Thu, 16 Mar 2023 13:50:22 +0000 Subject: [PATCH] [FIX] website: reset a form properly for each submission success type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, some behaviors of the forms after being submitted were problematic: - with the `On Success` option set on `Redirect`, when going back to a form after submitting it (with the browser arrows), the fields were still filled. - with the `Show Message` option selected, when going in edit mode when the message was displayed, the submit button was still "loading", even after saving. This commit solves this issues by properly resetting the form at each start and restoring the submit button loading effect when the message is displayed. task-2798576 closes odoo/odoo#118645 X-original-commit: ecb3bda77fab512a9790daf58447058f250f49e6 Signed-off-by: Vray Benjamin (bvr) Signed-off-by: Bojabza Soukéina (sobo) --- addons/website/static/src/snippets/s_website_form/000.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/website/static/src/snippets/s_website_form/000.js b/addons/website/static/src/snippets/s_website_form/000.js index 54038169806..dfa18b75bc8 100644 --- a/addons/website/static/src/snippets/s_website_form/000.js +++ b/addons/website/static/src/snippets/s_website_form/000.js @@ -71,6 +71,10 @@ import { sprintf } from "@web/core/utils/strings"; return res; }, start: function () { + // Reset the form first, as it is still filled when coming back + // after a redirect. + this.el.reset(); + // Prepare visibility data and update field visibilities const visibilityFunctionsByFieldName = new Map(); for (const fieldEl of this.el.querySelectorAll('[data-visibility-dependency]')) { @@ -364,7 +368,7 @@ import { sprintf } from "@web/core/utils/strings"; self.el.classList.add('d-none'); self.el.parentElement.querySelector('.s_website_form_end_message').classList.remove('d-none'); - return; + break; } default: { // Prevent double-clicking on the send button and