diff --git a/src/app/SearchPanel.js b/src/app/SearchPanel.js index 3f5a01d..fe34d3d 100644 --- a/src/app/SearchPanel.js +++ b/src/app/SearchPanel.js @@ -7,6 +7,13 @@ import { Delay, Heading1, useDebounce } from "./util"; import { Item, ItemListContainer, ItemListSkeleton } from "./Item"; import { itemAppearanceFragment } from "./OutfitPreview"; +/** + * SearchPanel shows item search results to the user, so they can preview them + * and add them to their outfit! + * + * It's tightly coordinated with SearchToolbar, using refs to control special + * keyboard and focus interactions. + */ function SearchPanel({ query, outfitState, @@ -22,6 +29,7 @@ function SearchPanel({ } }, [query, scrollContainerRef]); + // Sometimes we want to give focus back to the search field! const onMoveFocusUpToQuery = (e) => { if (searchQueryRef.current) { searchQueryRef.current.focus(); @@ -33,6 +41,8 @@ function SearchPanel({ { + // This will catch any Escape presses when the user's focus is inside + // the SearchPanel. if (e.key === "Escape") { onMoveFocusUpToQuery(e); } @@ -51,6 +61,14 @@ function SearchPanel({ ); } +/** + * SearchResults loads the search results from the user's query, renders them, + * and tracks the scroll container for infinite scrolling. + * + * For each item, we render a