department-of-veterans-affairs / vets-design-system-documentation

Repository for design.va.gov website
https://design.va.gov
37 stars 57 forks source link

va-search-input firing the onSubmit function twice #3117

Closed randimays closed 5 days ago

randimays commented 1 month ago

Bug Report

What happened

I noticed that va-search-input is firing the onSubmit function twice when the keyboard is used to submit the form (pressing "Enter"). In the video, you can see the /forms API call is made once when clicking to submit, and the second time it's submitted by hitting "Enter" and the API call is made twice. I think this is because the keyboard press event on the component is not using event.preventDefault(). I'm working on converting to this web component for the global search locally and noticing the same behavior.

https://github.com/user-attachments/assets/69d283fd-89c9-44de-86df-a2118274b0e8

What I expected to happen

onSubmit function should only fire one time regardless of how the search is submitted.

Reproducing

Prod example: https://www.va.gov/find-forms (and here's the code where that VaSearchInput is implemented)

Steps to reproduce:

  1. Go to va.gov/find-forms and open the Network tab
  2. Type in a search term such as "1010"
  3. Press "Enter" to submit the term
  4. Note that the /forms API is called twice when "Enter" is pressed

Urgency

How urgent is this request? Please select the appropriate option below and/or provide details

Details

Since this is a production bug, would it be possible to prioritize this soon? It is also blocking a couple of tickets I have in our current sprint.

caw310 commented 1 month ago

Hey team! Please add your planning poker estimate with Zenhub @Andrew565 @ataker @harshil1793 @it-harrison @jamigibbs @micahchiang @powellkerry @rmessina1010 @rsmithadhoc