Disable export buttons on form submit#11541
Disable export buttons on form submit#11541mekarpeles merged 2 commits intointernetarchive:masterfrom
Conversation
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Pull request overview
This PR simplifies the patron export button behavior by replacing complex download logic with a basic button disable on form submit. The previous implementation used fetch() to download CSVs programmatically and restore button state after completion. The new implementation simply disables the submit button when the form is submitted, allowing the native browser download mechanism to handle the export.
Key changes:
- Simplified
patron_exports.jsfrom ~144 lines to ~26 lines by removing custom fetch-based download logic - Added
patron-export-formCSS class to all export forms in the HTML template for easy selection - Updated initialization in
index.jsto select forms by class name and pass them to the simplified function
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| openlibrary/templates/account/import.html | Added patron-export-form class to all five export form elements for JavaScript targeting |
| openlibrary/plugins/openlibrary/js/patron_exports.js | Simplified from complex fetch-based download to basic button disable on submit |
| openlibrary/plugins/openlibrary/js/index.js | Updated initialization to select forms by class and pass NodeList to new function |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export function initPatronExportForms(elems) { | ||
| elems.forEach((form) => { | ||
| const submitButton = form.querySelector('input[type=submit]') | ||
| form.addEventListener('submit', () => { |
There was a problem hiding this comment.
Inconsistent quote style. The codebase predominantly uses single quotes for strings. Change "submit" to 'submit' for consistency.
Follows #11342
Disables data export buttons when the export form is submitted.
Technical
Testing
Screenshot
Stakeholders