Skip to content

Commit

Permalink
Prevent user input from being blocked in SearchView
Browse files Browse the repository at this point in the history
  • Loading branch information
HorusGoul committed Dec 13, 2024
1 parent 4b85e65 commit 53ce73a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions apps/pwa/src/components/search-view/SearchView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ function SearchView() {
const { i18n } = useLocale();
const navigate = useNavigate();
const params = useQuery();
const searchInput = useSearchInput("replace");
const query = searchInput.value.trim();
const { value, inputProps } = useSearchInput("replace");
const query = value.trim();
const openSearch = params.get("openSearch");
const deferredQuery = React.useDeferredValue(query);
const results = useContentSearch(deferredQuery);
Expand Down Expand Up @@ -66,7 +66,7 @@ function SearchView() {
<Icon name="arrow_back" />
</Button>

<input type="text" autoFocus {...searchInput} />
<input type="text" autoFocus {...inputProps} />

{isLoading && (
<div className={styles.spinner}>
Expand Down
9 changes: 6 additions & 3 deletions apps/pwa/src/components/search-view/useSearchInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ export function useSearchInput(type: "push" | "replace") {

return {
value,
onChange,
placeholder: i18n("Search_dots"),
"aria-label": i18n("Search"),
inputProps: {
defaultValue: value,
onChange,
placeholder: i18n("Search_dots"),
"aria-label": i18n("Search"),
},
};
}

0 comments on commit 53ce73a

Please sign in to comment.