nhsuk / nhsuk-frontend

NHS.UK frontend contains the code you need to start building user interfaces for NHS websites and services.
https://nhsuk.github.io/nhsuk-frontend/
MIT License
623 stars 107 forks source link

Add submit debounce functionality #796

Closed jiveturkeyJay closed 1 year ago

jiveturkeyJay commented 2 years ago

Bug Report/Issue report

Not really a bug. On NBS we have had an issue with users double clicking and submitting forms twice. This has led some users to an error page, even though they have booked a vaccine. They then proceed to book another vaccine as they are told to. It seems some users routinely double click and cause extra load on the servers by doing so.

The solution is to add a debounce function similar to what the gov.uk site has https://github.com/alphagov/govuk-frontend/blob/main/src/govuk/components/button/button.js

I used a solution based on the approach that the gov.uk site uses.

This is a small slack thread discussing the issue https://nhsuk.slack.com/archives/CCPLQ9YAJ/p1637328178007900

henocookie commented 2 years ago

Something we could look at implementing in nhsuk-frontend @DomBaker @truecroft2? 👀

Worth testing and assessing the impacts this could have for people with slower internet connections and just how long we would wait to discount a double-click of a button