Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions strictdoc/export/html/_static/action_button_guard.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,17 @@
document.addEventListener('turbo:submit-end', resetPending);
document.addEventListener('turbo:frame-render', resetPending);

// Clear stale validation errors from a form as soon as it is resubmitted,
// rather than leaving them on screen until the new response arrives.
document.addEventListener('turbo:submit-start', function (event) {
const form = event.target;
if (!(form instanceof HTMLFormElement)) return;
form.querySelectorAll('sdoc-form-error').forEach(function (errorEl) {
errorEl.remove();
});
form.querySelectorAll('[errors]').forEach(function (fieldEl) {
fieldEl.removeAttribute('errors');
});
});

})();
Loading