Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): guard radix select typeahead focus on unmounted items (#17373)

cursor[bot]7e9d6c970040
diff --git a/patches/@[email protected] b/patches/@[email protected]
new file mode 100644
index 0000000000..6083cf2887
--- /dev/null
+++ b/patches/@[email protected]
@@ -0,0 +1,26 @@
+diff --git a/dist/index.js b/dist/index.js
+index dc37ac4a018a086c4244a09a67215dbaa9b4de65..f93254344e337621db1377f65eeb2a0fa44b011f 100644
+--- a/dist/index.js
++++ b/dist/index.js
+@@ -448,7 +448,7 @@ var SelectContentImpl = React.forwardRef(
+ const currentItem = enabledItems.find((item) => item.ref.current === document.activeElement);
+ const nextItem = findNextItem(enabledItems, search, currentItem);
+ if (nextItem) {
+- setTimeout(() => nextItem.ref.current.focus());
++ setTimeout(() => nextItem.ref.current?.focus());
+ }
+ });
+ const itemRefCallback = React.useCallback(
+diff --git a/dist/index.mjs b/dist/index.mjs
+index f9b94f39dfddef678ef3086354f8d7413ae27e52..9c06f97c1b81a252cf17c448d92364a7dfd77cae 100644
+--- a/dist/index.mjs
++++ b/dist/index.mjs
+@@ -381,7 +381,7 @@ var SelectContentImpl = React.forwardRef(
+ const currentItem = enabledItems.find((item) => item.ref.current === document.activeElement);
+ const nextItem = findNextItem(enabledItems, search, currentItem);
+ if (nextItem) {
+- setTimeout(() => nextItem.ref.current.focus());
++ setTimeout(() => nextItem.ref.current?.focus());
+ }
+ });
+ const itemRefCallback = React.useCallback(
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ef5b60148a..27e8f61fc9 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -74,6 +74,7 @@ packageExtensionsChecksum: sha256-WsueXkDwaA1Mur66bfJz2RLd0+lO1INOq2n8H30Pf8M=
patchedDependencies:
'@radix-ui/[email protected]': fb2bc2e96ad2c31dcb5860e509374a512fa08b1fade5805e3ae2dc72dcd68a0b
+ '@radix-ui/[email protected]': c82ebbf31f9b961dce52b75bdeb703852ddf4a1ecea0b96b284218f0c1c07f23
[email protected]: 298683aaa31566643f1899990a065b342ad777d8613f50a25ddc44dd46fb5b4d
[email protected]: 4b892c72909f6878974d9b325e85a5e369e3e676cef3d3eb563f822660218c60
@@ -638,7 +639,7 @@ importers:
'@radix-ui/react-select':
specifier: ^2.2.6
+ version: 2.2.6(patch_hash=c82ebbf31f9b961dce52b75bdeb703852ddf4a1ecea0b96b284218f0c1c07f23)(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])
'@radix-ui/react-separator':
specifier: ^1.1.8
@@ -15483,7 +15484,7 @@ snapshots:
'@types/react': 19.2.14
'@types/react-dom': 19.2.3(@types/[email protected])
+ '@radix-ui/[email protected](patch_hash=c82ebbf31f9b961dce52b75bdeb703852ddf4a1ecea0b96b284218f0c1c07f23)(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':
dependencies:
'@radix-ui/number': 1.1.1
'@radix-ui/primitive': 1.1.3
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 3ef2333346..f7c6256fa1 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -125,6 +125,11 @@ patchedDependencies:
# runs), e.g. opening a row-actions dropdown while a table re-renders.
# Still unfixed upstream as of 1.1.19; remove once Radix guards focusFirst.
'@radix-ui/[email protected]': patches/@[email protected]
+ # Select typeahead schedules nextItem.ref.current.focus() in a setTimeout.
+ # If the item unmounts before the timeout (dynamic option lists, closing the
+ # menu, a sibling field remounting items), the ref is null and throws.
+ # Fixed upstream in 2.3.7; remove this patch when we bump.
+ '@radix-ui/[email protected]': patches/@[email protected]
# The document-level drag handlers crash when a panel group unmounts
# mid-drag: setPointerCapture on the detached separator throws