🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(web): drop the stuck focus ring on the sidebar version badge (#18098)
Der Gerät27c23a3c9ebc
diff --git a/web/src/components/nav/AppSidebar/AppSidebar.tsx b/web/src/components/nav/AppSidebar/AppSidebar.tsxindex f5a584ffb1..b0b4197972 100644--- a/web/src/components/nav/AppSidebar/AppSidebar.tsx+++ b/web/src/components/nav/AppSidebar/AppSidebar.tsx@@ -591,6 +591,22 @@ const VersionLabel = ({ state }: { state: SidebarVersionState }) => {return assertUnreachable(update.updateType);}, [update]);+ // Radix returns focus to the trigger when the menu closes, and the browser+ // treats that programmatic focus as `:focus-visible`, so the Button's+ // `focus-visible:ring-2` ring is left showing on the badge after a+ // mouse-driven open/close. Keyboard users must keep that ring, so the focus+ // restore is suppressed only for an interaction that never used the keyboard.+ //+ // `pointerOnly` therefore has to be cleared by a key press anywhere in the+ // interaction, not only on the trigger: the menu is portalled, so once it is+ // open every key event lands on the content instead. A mouse-opened menu+ // closed with Escape or Enter is a keyboard interaction and must get focus+ // back on the trigger.+ const pointerOnly = React.useRef(false);+ const noteKeyboardUse = () => {+ pointerOnly.current = false;+ };+return (<DropdownMenu><DropdownMenuTrigger asChild>@@ -598,6 +614,10 @@ const VersionLabel = ({ state }: { state: SidebarVersionState }) => {variant="ghost"size="xs"className="text-muted-foreground h-5 max-w-full min-w-0 translate-y-px py-0 text-[0.625rem] leading-none"+ onPointerDown={() => {+ pointerOnly.current = true;+ }}+ onKeyDown={noteKeyboardUse}><span className="truncate" title={versionText}>{versionText}@@ -614,7 +634,19 @@ const VersionLabel = ({ state }: { state: SidebarVersionState }) => {)}</Button></DropdownMenuTrigger>- <DropdownMenuContent onClick={(e) => e.stopPropagation()}>+ <DropdownMenuContent+ onClick={(e) => e.stopPropagation()}+ // Both hooks are needed: Radix's DismissableLayer handles Escape before+ // it reaches the content's own onKeyDown, while onKeyDown covers the+ // arrow/Enter/typeahead keys used to pick an item.+ onKeyDown={noteKeyboardUse}+ onEscapeKeyDown={noteKeyboardUse}+ onCloseAutoFocus={(event) => {+ if (!pointerOnly.current) return;+ pointerOnly.current = false;+ event.preventDefault();+ }}+ >{update ? (<><DropdownMenuLabel>