From 5766bd53737b19a9e80e8a432ac74e93cf50df71 Mon Sep 17 00:00:00 2001
From: Kalle <38327916+Sendouc@users.noreply.github.com>
Date: Thu, 4 Jun 2026 20:42:02 +0300
Subject: [PATCH] Fix seasons page dropdown missing S0, only wrap Autocomplete
when needed
---
.../elements/Select.browser.test.tsx | 61 ++++++++++++++
app/components/elements/Select.tsx | 79 +++++++++++--------
2 files changed, 107 insertions(+), 33 deletions(-)
create mode 100644 app/components/elements/Select.browser.test.tsx
diff --git a/app/components/elements/Select.browser.test.tsx b/app/components/elements/Select.browser.test.tsx
new file mode 100644
index 000000000..5115ce5c4
--- /dev/null
+++ b/app/components/elements/Select.browser.test.tsx
@@ -0,0 +1,61 @@
+import { describe, expect, test } from "vitest";
+import { render } from "vitest-browser-react";
+import {
+ SendouSelect,
+ SendouSelectItem,
+ SendouSelectItemSection,
+} from "./Select";
+
+const SECTIONS = [
+ {
+ heading: "2023",
+ key: "2023",
+ items: [
+ { id: 2, name: "Season 2" },
+ { id: 1, name: "Season 1" },
+ { id: 0, name: "Season 0" },
+ ],
+ },
+];
+
+function GroupedSelect(props: { search?: { placeholder?: string } }) {
+ return (
+
+ {({ heading, items, key }: (typeof SECTIONS)[number]) => (
+
+ {items.map((item) => (
+
+ {item.name}
+
+ ))}
+
+ )}
+
+ );
+}
+
+describe("SendouSelect", () => {
+ test("renders an item with a falsy (0) key when there is no search", async () => {
+ const screen = await render( );
+
+ await screen.getByRole("button").click();
+
+ await expect
+ .element(screen.getByRole("option", { name: "Season 0" }))
+ .toBeVisible();
+ });
+
+ test("filters items when search is enabled", async () => {
+ const screen = await render( );
+
+ await screen.getByRole("button").click();
+ await screen.getByRole("searchbox").fill("Season 1");
+
+ await expect
+ .element(screen.getByRole("option", { name: "Season 1" }))
+ .toBeVisible();
+ await expect
+ .element(screen.getByRole("option", { name: "Season 2" }))
+ .not.toBeInTheDocument();
+ });
+});
diff --git a/app/components/elements/Select.tsx b/app/components/elements/Select.tsx
index 53c80e098..04de433d7 100644
--- a/app/components/elements/Select.tsx
+++ b/app/components/elements/Select.tsx
@@ -93,6 +93,25 @@ export function SendouSelect({
}
};
+ const listBox = (
+
+ (
+ {t("common:noResults")}
+ )}
+ >
+ {children}
+
+
+ );
+
+ // The Autocomplete wrapper filters the collection, but its filtering drops
+ // items with a falsy key (e.g. `0`). When there is nothing to filter we skip
+ // it entirely so such items always render.
+ const filterable = !!search || isControlled || !!filter;
+
return (
({
{clearable ? : null}
-
- {search ? (
-
-
-
-
-
-
-
- ) : null}
-
- (
- {t("common:noResults")}
- )}
- >
- {children}
-
-
-
+ {filterable ? (
+
+ {search ? (
+
+
+
+
+
+
+
+ ) : null}
+ {listBox}
+
+ ) : (
+ listBox
+ )}
);