Skip to content

Commit fe5a7fc

Browse files
authored
Merge pull request #226 from southworks/staging
[fix] Added focus on Search component (#199) and translation corruption (#212)
2 parents c14d358 + d4d038a commit fe5a7fc

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/components/Search/FilterDropdown.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import type { Filters } from "./PageFind";
1313
import type { CollectionEntry } from "astro:content";
1414
import { APPLICATION_COMPATIBILITY, GAME_AUTO_SR, GAME_COMPATIBILITY } from "../../config/enumerations";
15-
import { t } from "i18next";
15+
import i18next, { t } from "i18next";
1616
import { updateLanguage } from "../../util/updateLanguage";
1717

1818
type FilterKey = "auto_super_resolution.compatibility" | "category" | "compatibility";
@@ -44,10 +44,10 @@ const FilterDropdown = ({
4444

4545
}) => {
4646
const _ = updateLanguage(window.location);
47-
const filters = type === "applications" ? getApplicationFilters() : getGameFilters();
47+
const [filters, setFilters] = createSignal<{ key: FilterKey; name: string }[]>([]);
4848

4949
const [showFilters, setShowFilters] = createSignal<Record<string, boolean>>(
50-
filters.reduce(
50+
filters().reduce(
5151
(p, f) => ({
5252
...p,
5353
[f.key]: false,
@@ -70,7 +70,7 @@ const FilterDropdown = ({
7070
const handleClick = (event: MouseEvent) => {
7171
if (!ref.contains(event.target as Node)) {
7272
setShowFilters(
73-
filters.reduce(
73+
filters().reduce(
7474
(p, f) => ({
7575
...p,
7676
[f.key]: false,
@@ -81,8 +81,14 @@ const FilterDropdown = ({
8181
}
8282
};
8383

84-
onMount(() => {
84+
onMount(async () => {
8585
document.addEventListener("click", handleClick);
86+
let filtersValues = type === "applications" ? getApplicationFilters() : getGameFilters();
87+
if (filtersValues.some(p => p.name.includes("game_filters") || p.name.includes("application_filters"))) {
88+
await i18next.reloadResources();
89+
filtersValues = type === "applications" ? getApplicationFilters() : getGameFilters();
90+
}
91+
setFilters(filtersValues);
8692
});
8793

8894
onCleanup(() => {
@@ -108,7 +114,7 @@ const FilterDropdown = ({
108114

109115
return (
110116
<div class=" flex " ref={ref!}>
111-
<For each={filters}>
117+
<For each={filters()}>
112118
{(filter) => (
113119
<div class="relative w-36 h-full flex-shrink-0 z-10 inline-flex text-sm font-medium text-center last:rounded-r-full first:rounded-l-full first:md:rounded-l-none border-l focus:ring-4 focus:outline-none bg-neutral-700 hover:bg-neutral-600 focus:ring-neutral-700 text-white border-neutral-600">
114120
<button

src/components/Search/PageFind.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ const PageFind = ({
292292
? t('applications.search_placeholder')
293293
: t('games.search_placeholder')
294294
}
295+
autofocus
295296
name="project-search"
296297
value={search().query ?? ""}
297298
onInput={(e) =>

0 commit comments

Comments
 (0)