mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
Improve React Doctor score and badge (#1127)
* fix(react doctor): improve quality score and badge * fix(react doctor): address review feedback * fix(review): address final bot feedback
This commit is contained in:
@@ -8,11 +8,11 @@ import debounce from 'lodash/debounce';
|
||||
|
||||
const CatalogSearch = () => {
|
||||
const { t } = useTranslation();
|
||||
const location = useLocation();
|
||||
const { pathname, search } = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const [searchState, setSearchState] = useState({ open: false, value: '' });
|
||||
const { setSearchFilter, clearSearchFilter } = useCatalogFiltersStore();
|
||||
const queryParam = new URLSearchParams(location.search).get('q') ?? '';
|
||||
const queryParam = new URLSearchParams(search).get('q') ?? '';
|
||||
const openSearch = !!queryParam || searchState.open;
|
||||
const inputValue = searchState.open || searchState.value ? searchState.value : queryParam;
|
||||
|
||||
@@ -27,17 +27,17 @@ const CatalogSearch = () => {
|
||||
|
||||
const updateURL = useCallback(
|
||||
(searchText: string) => {
|
||||
const urlParams = new URLSearchParams(location.search);
|
||||
const urlParams = new URLSearchParams(search);
|
||||
if (searchText.trim()) {
|
||||
urlParams.set('q', searchText);
|
||||
} else {
|
||||
urlParams.delete('q');
|
||||
}
|
||||
const newSearch = urlParams.toString();
|
||||
const newPath = location.pathname + (newSearch ? `?${newSearch}` : '');
|
||||
const newPath = pathname + (newSearch ? `?${newSearch}` : '');
|
||||
navigate(newPath, { replace: true });
|
||||
},
|
||||
[location.pathname, location.search, navigate],
|
||||
[pathname, search, navigate],
|
||||
);
|
||||
|
||||
const debouncedSetSearchFilter = useMemo(
|
||||
|
||||
Reference in New Issue
Block a user