Fix double submission on template change#726
Merged
matthiask merged 6 commits intofeincms:mainfrom Feb 11, 2026
Merged
Conversation
disable all submit buttons during page reload after template change to prevent users from accidentally submitting the form mutliple times.
for more information, see https://pre-commit.ci
matthiask
approved these changes
Feb 10, 2026
Member
matthiask
left a comment
There was a problem hiding this comment.
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") |
Member
There was a problem hiding this comment.
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") |
- 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.
for more information, see https://pre-commit.ci
… submit buttons are correctly disabled upon changing the template
for more information, see https://pre-commit.ci
Contributor
Author
|
thank you for the feedback! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Result: Buttons are disabled instantly; the page reloads correctly; no duplicate page is created.
Related Issue
Fixes #677