USEPA / haztrak

An open-source web app that illustrates how waste management software can interface with RCRAInfo to track hazardous waste electronically
https://usepa.github.io/haztrak/
MIT License
45 stars 19 forks source link

Debounce transporter input #729

Closed sheckathorne closed 3 weeks ago

sheckathorne commented 3 weeks ago

Description

Debounces the transporter input in the manifest form while also reducing the minimum number of characters from 5 to 2 before results begin populating. Debounce will limit the number of requests made to the server when typing-to-search while the reduction in characters will allow the user to display results earlier.

Issue ticket number and link

https://github.com/USEPA/haztrak/issues/727

Checklist

dpgraham4401 commented 3 weeks ago

Thanks @sheckathorne!

I know we already discussed this, I'll review this before the end of this week.

dpgraham4401 commented 3 weeks ago

I notice that it's still sending a request with an empty epaID when the user moves focus away from the select input, which I believe it was doing before anyways(?)

image

We can remove that call by modifying the skip option in the useSearchRcraSitesQuery

  const { data } = useSearchRcraSitesQuery(
    {
      siteType: handlerType,
      siteId: debouncedInputValue,
    },
    { skip: skip || debouncedInputValue === '' }
  );

@sheckathorne, do you have the time to modify the PR to fix this? I would hate to not clear this technical debt while we're already here. If not I can make these changes.

sheckathorne commented 3 weeks ago

Sorry I missed your comments, I have been traveling. I will make these edits today and also admit that I had some help with writing only the tests :)