department-of-veterans-affairs / va.gov-cms

Editor-centered management for Veteran-centered content.
https://prod.cms.va.gov
GNU General Public License v2.0
96 stars 70 forks source link

[Search] DRY up SearchDropdownComponent typeahead handler #11513

Open ryguyk opened 1 year ago

ryguyk commented 1 year ago

Status

[2024-08-01] From Randi: I discovered a defect in the va-search-input web component that already exists in production in Find Forms. Slack thread This defect is blocking the completion of this ticket unfortunately. Hopefully we can get some eyes on it soon: https://github.com/department-of-veterans-affairs/vets-design-system-documentation/issues/3117

Description

SearchDropdownComponent currently accepts a function fetchSuggestions as a property. This component is currently called in three places, each of which create a separate instance of a function to pass to this component:

It seems initially confusing why this logic is being passed in rather than defined inside the component, as this component is only used for site-wide search. It's conceivable, though, that this component might be used to search something else, and that the current architecture makes it flexible enough to do so.

Regardless, we need to DRY this up. The same code is repeated three times to be passed into the component in the three places indicated above. We have two options:

  1. If it seems reasonable to keep this design whereby this component accepts the functionality as a property, we should move that functionality to a reusable function that can be imported in each of the three places noted above.
  2. Otherwise, we should move the functionality inside SearchDropdownComponent.
    • We could define it as a default property that could be overridden.
    • We could remove it as a property and simply make this component more specific to site-wide search.

Acceptance Criteria

randimays commented 4 months ago

Pulling in as stretch as it is a great companion ticket to #17176

randimays commented 4 months ago

Typeahead web component still has issues. I've reported to DST. Moving this back to Blocked.

Slack thread: https://dsva.slack.com/archives/C01DBGX4P45/p1714663661141389?thread_ts=1714054912.852109&cid=C01DBGX4P45

randimays commented 1 month ago

@FranECross @jilladams This ticket goes with https://github.com/department-of-veterans-affairs/va.gov-cms/issues/17176 (and they were both blocked by the same defect that now seems to be resolved); should we pull it into the current sprint?

jilladams commented 1 month ago

Seems like you prob have capacity, dST blocker is resolved -- I have no objections! (And defer to Fran)

FranECross commented 1 month ago

@randimays Sounds good, thanks for thinking of it! (added Sprint 9 tag; pulled into sprint)

randimays commented 1 month ago

I discovered a defect in the va-search-input web component that already exists in production in Find Forms. Slack thread: https://dsva.slack.com/archives/C01DBGX4P45/p1722438937787339

This defect is blocking the completion of this ticket unfortunately. Hopefully we can get some eyes on it soon: https://github.com/department-of-veterans-affairs/vets-design-system-documentation/issues/3117