mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
fix: clear filters no longer shows up after searching and clearing the search bar
This commit is contained in:
1 parent
17755641a1
commit
4bc255a624
3 files changed
+5
-15
No files matched your search
@@ -21,27 +21,17 @@ export function SearchBar({ topResult, skeleton, onSelect }: SearchBarProps) {
|
||||
const input = useRef<HTMLInputElement>(null);
|
||||
const performSearch = useCallback(
|
||||
debounce(() => {
|
||||
// tankFiltersStore.setState({ searching: false });
|
||||
$tankFilters.setKey('searching', false);
|
||||
|
||||
if (!input.current) return;
|
||||
|
||||
const sanitized = input.current.value.trim();
|
||||
|
||||
// tankFiltersStore.setState({
|
||||
// search: sanitized.length === 0 ? undefined : sanitized,
|
||||
// });
|
||||
$tankFilters.setKey(
|
||||
'search',
|
||||
sanitized.length === 0 ? undefined : sanitized,
|
||||
);
|
||||
$tankFilters.setKey('search', sanitized.length === 0 ? null : sanitized);
|
||||
}, 500),
|
||||
[],
|
||||
);
|
||||
const handleChange = useCallback(() => {
|
||||
// if (!tankFiltersStore.getState().searching) {
|
||||
// tankFiltersStore.setState({ searching: true });
|
||||
// }
|
||||
if (!tankFilters.searching) {
|
||||
$tankFilters.setKey('searching', true);
|
||||
}
|
||||
@@ -69,7 +59,7 @@ export function SearchBar({ topResult, skeleton, onSelect }: SearchBarProps) {
|
||||
<TextField.Root
|
||||
variant="classic"
|
||||
disabled={skeleton}
|
||||
defaultValue={tankFilters.search}
|
||||
defaultValue={tankFilters.search ?? undefined}
|
||||
style={{ flex: 1 }}
|
||||
ref={input}
|
||||
placeholder={strings.website.common.tank_search.search_bar_hint}
|
||||
|
||||
@@ -60,7 +60,7 @@ export const TankSearch = memo<TankSearchProps>(
|
||||
const tankFilters = useStore($tankFilters);
|
||||
const tankopediaSort = useStore($tankopediaSort);
|
||||
const tanksFiltered = useMemo(() => {
|
||||
if (tankFilters.search === undefined) {
|
||||
if (tankFilters.search === null) {
|
||||
const filtered = awaitedTanksDefinitionsArray.filter((tank) =>
|
||||
filterTank(tankFilters, tank),
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@ export interface TankFilters {
|
||||
classes: TankClass[];
|
||||
types: TankType[];
|
||||
testing: 'include' | 'exclude' | 'only';
|
||||
search?: string;
|
||||
search: string | null;
|
||||
searching: boolean;
|
||||
gunType: CaseType<GunDefinition>[];
|
||||
shells: [ShellType | null, ShellType | null, ShellType | null];
|
||||
@@ -30,7 +30,7 @@ export const initialTankFilters: TankFilters = {
|
||||
classes: [],
|
||||
types: [],
|
||||
testing: 'include',
|
||||
search: undefined,
|
||||
search: null,
|
||||
searching: false,
|
||||
gunType: [],
|
||||
shells: [null, null, null],
|
||||
|
||||
Reference in new issue
Block a user