- Issue created by @jessica-atom
- 🇧🇪Belgium weseze
Also have this issue while using Firefox or Edge back buttons. Not an issue in Chrome.
- 🇧🇪Belgium weseze
Seems this is issue is also present in plain vanilla Drupal core forms: 🐛 Prevention of multiple submits blocks use of back navigation Active
Here is a workaround using Javascript.
You only need to include this file on webpages where you want to prevent this bug to happen.
The idea is simple : if the page was loaded from browser cache, i want to force the refresh so drupal may rebuild the form./** * @file * This script forces the page to fully load, without caching. * This is helpfull to prevent forms being broken when accessed through the back button. */ (function (Drupal) { Drupal.behaviors.preventCache = { attach: function (context, settings) { // Ensure this runs only once per page load if (!context.querySelector || context.querySelector('[data-drupal-cache-prevented]')) { return; } // Reload the page if loaded from cache (back/forward navigation) window.onpageshow = function (event) { if (event.persisted) { location.reload(); } }; // Mark the page to avoid duplicate execution document.body.setAttribute('data-drupal-cache-prevented', 'true'); } }; })(Drupal);