From fe9d5881037e1e2f3f24bed3b1c95bc2d0b17682 Mon Sep 17 00:00:00 2001 From: Oleh Omelchenko Date: Fri, 12 Jun 2026 14:45:45 +0300 Subject: [PATCH] Sort control: open with focus on the checked option, not the first --- src/app/components/SortControl.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/components/SortControl.tsx b/src/app/components/SortControl.tsx index 1bcf262..013cb80 100644 --- a/src/app/components/SortControl.tsx +++ b/src/app/components/SortControl.tsx @@ -109,7 +109,12 @@ export function SortControl() { popRef.current = node; if (node) { place(); - node.querySelector('[aria-checked="true"], button')?.focus(); + // Two queries, not one selector list — `querySelector('a, b')` returns the + // first match in document order, which would always be the first button. + const target = + node.querySelector('[aria-checked="true"]') ?? + node.querySelector('button'); + target?.focus(); } }, [place],