Skip to content

Fix double submission on template change#726

Merged
matthiask merged 6 commits intofeincms:mainfrom
hey-granth:main
Feb 11, 2026
Merged

Fix double submission on template change#726
matthiask merged 6 commits intofeincms:mainfrom
hey-granth:main

Conversation

@hey-granth
Copy link
Contributor

Description
Disables all submit buttons immediately after the "Change Template" event triggers a form submission.

Problem
When a user selects a new template, item_editor.js simulates a click on the _save button to reload the page with new regions. Previously, the submit buttons remained active during this process. If a user manually clicked "Save" or "Save and continue" before the page reload completed, the browser issued a second POST request, frequently resulting in duplicate page objects.

Solution
Added a synchronous disabling of all input[type=submit] elements within the on_template_key_changed function, immediately following the simulated save event.

Testing

  • Open an existing Page in the admin interface.
  • Change the Template dropdown.
  • Immediately attempt to click "Save and continue editing".

Result: Buttons are disabled instantly; the page reloads correctly; no duplicate page is created.

Related Issue
Fixes #677

hey-granth and others added 2 commits February 10, 2026 15:17
disable all submit buttons during page reload after template change to prevent users from accidentally submitting the form mutliple times.
Copy link
Member

@matthiask matthiask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

If possible I'd slightly prefer a LiveServerTestCase-based test which actually verifies the behavior to the current test which verifies that the code isn't changed. Do you think it would be reasonably easy to add such a test?

invoked. See Issue #372 */
form_element.find("[type=submit][name=_save]").click()
/* Disable all submit buttons to prevent double submission while page reloads */
form_element.find("input[type=submit]").attr("disabled", "disabled")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also handle button elements here, not just input[type=submit]. Something like this:

Suggested change
form_element.find("input[type=submit]").attr("disabled", "disabled")
form_element.find("input[type=submit], button").attr("disabled", "disabled")

hey-granth and others added 4 commits February 10, 2026 21:07
- Disable all submit buttons (input and button elements) immediately after
  triggering save when template is changed in the admin interface
- Add regression test that verifies the fix is present in item_editor.js
- Test uses BASEDIR from settings for robust path construction

This prevents users from accidentally submitting the form twice while
the page is reloading after a template change.
… submit buttons are correctly disabled upon changing the template
@hey-granth
Copy link
Contributor Author

thank you for the feedback!
i have made the necessary changes, including adding a LiverServerTestCase based test, and I also implemented BASEDIR settings value in the tests as suggested.
Hope this solves all the mentioned problems in this issue.

@matthiask matthiask merged commit 20c948d into feincms:main Feb 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The save buttons should be disabled after change template

2 participants