From 02a188a08059e7aebb6834b9c5801b28d00ad149 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Fri, 14 Mar 2025 13:47:02 -0700 Subject: [PATCH] fixed e2e --- .../javascripts/preventDuplicateFormSubmissions.js | 12 +++++++++--- .../components/components/button/template.njk | 2 +- app/templates/views/check/preview.html | 5 ++++- app/templates/views/notifications/preview.html | 3 +-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/preventDuplicateFormSubmissions.js b/app/assets/javascripts/preventDuplicateFormSubmissions.js index a58f2a8b5..e3221d9d2 100644 --- a/app/assets/javascripts/preventDuplicateFormSubmissions.js +++ b/app/assets/javascripts/preventDuplicateFormSubmissions.js @@ -13,11 +13,17 @@ } else { $submitButton.data('clicked', 'true'); - $submitButton.prop('disabled', true); - setTimeout(renableSubmitButton($submitButton), 10000); + if ($submitButton.is('[name="Send"], [name="Schedule"]')) { + $submitButton.prop('disabled', true); + + setTimeout(() => { + renableSubmitButton($submitButton); + }, 10000); + } else { + setTimeout(renableSubmitButton($submitButton), 1500); + } } - }; let renableSubmitButton = $submitButton => () => { diff --git a/app/templates/components/components/button/template.njk b/app/templates/components/components/button/template.njk index dc81ebf11..01bc649ac 100644 --- a/app/templates/components/components/button/template.njk +++ b/app/templates/components/components/button/template.njk @@ -16,7 +16,7 @@ {#- Define common attributes we can use for both button and input types #} -{%- set buttonAttributes %}{% if params.name %} name="{{ params.name }}"{% endif %} type="{{ params.type if params.type else 'submit' }}"{% if params.disabled %} disabled="disabled" aria-disabled="true"{% endif %}{% if params.preventDoubleClick %} data-prevent-double-click="true"{% endif %}{% endset %} +{%- set buttonAttributes %}{% if params.name %} name="{{ params.name | trim }}"{% endif %} type="{{ params.type if params.type else 'submit' }}"{% if params.disabled %} disabled="disabled" aria-disabled="true"{% endif %}{% if params.preventDoubleClick %} data-prevent-double-click="true"{% endif %}{% endset %} {#- Actually create a button... or a link! #} diff --git a/app/templates/views/check/preview.html b/app/templates/views/check/preview.html index 6e0122499..091ba345f 100644 --- a/app/templates/views/check/preview.html +++ b/app/templates/views/check/preview.html @@ -101,6 +101,9 @@ {% set button_text %} {{ "Schedule" if scheduled_for else 'Send'}} {% endset %} - {{ usaButton({ "text": button_text }) }} + {{ usaButton({ + "text": button_text, + "name": button_text + }) }} {% endblock %} diff --git a/app/templates/views/notifications/preview.html b/app/templates/views/notifications/preview.html index 16874181c..536288d9a 100644 --- a/app/templates/views/notifications/preview.html +++ b/app/templates/views/notifications/preview.html @@ -83,8 +83,7 @@ {% endset %} {{ usaButton({ "text": button_text, - "type": submit, - "preventDoubleClick": True, + "name": button_text }) }} {% endif %}