Fix global search flicker

This commit is contained in:
Kalle
2026-09-23 18:49:38 +03:00
parent 23875c7c67
commit 359390292a
3 changed files with 17 additions and 1 deletions

View File

@@ -18,6 +18,7 @@ export function SendouRadioGroup({
isDisabled,
className,
"aria-label": ariaLabel,
onMouseDown,
children,
}: {
value: string | null;
@@ -25,12 +26,18 @@ export function SendouRadioGroup({
isDisabled?: boolean;
className?: string;
"aria-label"?: string;
onMouseDown?: (e: React.MouseEvent) => void;
children: React.ReactNode;
}) {
const name = React.useId();
return (
<div role="radiogroup" aria-label={ariaLabel} className={className}>
<div
role="radiogroup"
aria-label={ariaLabel}
className={className}
onMouseDown={onMouseDown}
>
<RadioGroupContext value={{ name, value, isDisabled, onChange }}>
{children}
</RadioGroupContext>

View File

@@ -343,6 +343,7 @@ function GlobalSearchContent({
onChange={handleSearchTypeChange}
aria-label="Search type"
className={styles.searchTypeRadioGroup}
onMouseDown={preventFocusLeavingInput}
>
{SEARCH_TYPES.map((type) => (
<SendouRadio
@@ -418,6 +419,10 @@ function GlobalSearchContent({
);
}
function preventFocusLeavingInput(e: React.MouseEvent) {
e.preventDefault();
}
type SearchResult = NonNullable<SearchLoaderData>["results"][number];
function getResultKey(result: SearchResult): string {

View File

@@ -0,0 +1,4 @@
---
type: bug
---
Switching tabs in search no longer makes the search field flicker