2138 - Change cancel button to uploading button for CSV

This commit is contained in:
Jonathan Bobel
2025-03-26 14:49:11 -04:00
parent 7458acdab1
commit d79ece2d01
4 changed files with 36 additions and 9 deletions

View File

@@ -5,9 +5,21 @@
this.submit = () => this.$form.trigger('submit');
this.showCancelButton = () => $('.file-upload-button', this.$form).replaceWith(`
<a href="" class='usa-button usa-button--secondary'>Cancel upload</a>
`);
this.showCancelButton = () => {
$('.file-upload-button', this.$form).replaceWith(`
<button class='usa-button uploading-button' aria-disabled="true" tabindex="0">
Uploading<span class="dot-anim" aria-hidden="true"></span>
</button>
`);
// Screen reader live region
const $srStatus = $('#upload-status-live');
if ($srStatus.length) {
$srStatus.text('File is uploading');
} else {
this.$form.prepend(`<span id="upload-status-live" class="usa-sr-only" role="status" aria-live="polite">File is uploading</span>`);
}
};
this.start = function(component) {
@@ -17,7 +29,7 @@
// users see a button that looks like the others on the site.
this.$form.find('label.file-upload-button').addClass('usa-button margin-bottom-1').attr( {role: 'button', tabindex: '0'} );
// Clear the form if the user navigates back to the page
$(window).on("pageshow", () => this.$form[0].reset());

View File

@@ -344,3 +344,17 @@ h2.recipient-list {
}
}
}
// Button ellipses loading
.dot-anim::after {
content: '.';
animation: dotPulse 1.5s steps(3, end) infinite;
}
@keyframes dotPulse {
0% { content: ''; }
33% { content: '.'; }
66% { content: '..'; }
100% { content: '...'; }
}

View File

@@ -1,5 +1,5 @@
@forward "uswds-theme";
@forward "uswds";
@forward "uswds-theme-custom-styles";
@forward "legacy-styles";
@forward "main";
@forward "data-visualization";

View File

@@ -72,10 +72,11 @@ describe('File upload', () => {
});
test("It should add a link to cancel the upload by reloading the page", () => {
expect(form.querySelector("a[href='']")).not.toBeNull();
test("It should display a disabled Uploading button", () => {
const uploadingButton = form.querySelector("button.uploading-button");
expect(uploadingButton).not.toBeNull();
expect(uploadingButton.textContent).toMatch(/Uploading/);
expect(uploadingButton.getAttribute('aria-disabled')).toBe("true");
});
});