Skip to content

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

fix(ui): guard null item refs in Radix roving-focus focusFirst (#15764)

Nikita Kabardinb5ee1fc92399
diff --git a/patches/@[email protected] b/patches/@[email protected]
new file mode 100644
index 0000000000..685a145dba
--- /dev/null
+++ b/patches/@[email protected]
@@ -0,0 +1,24 @@
+diff --git a/dist/index.js b/dist/index.js
+index b49982f5a62521aaf0be8831ad7c86d661ab04a0..be7e8833cc63f8f6b6f2c8c2ef88999bb13e5652 100644
+--- a/dist/index.js
++++ b/dist/index.js
+@@ -250,6 +250,7 @@ function getFocusIntent(event, orientation, dir) {
+ function focusFirst(candidates, preventScroll = false) {
+ const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
+ for (const candidate of candidates) {
++ if (!candidate) continue;
+ if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
+ candidate.focus({ preventScroll });
+ if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
+diff --git a/dist/index.mjs b/dist/index.mjs
+index 08aaabcdb5402c74bcbd935a34e2b7f4a50fdfc0..497b7f08f6a8bce319148ab43bf7e660ff4fe1db 100644
+--- a/dist/index.mjs
++++ b/dist/index.mjs
+@@ -211,6 +211,7 @@ function getFocusIntent(event, orientation, dir) {
+ function focusFirst(candidates, preventScroll = false) {
+ const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
+ for (const candidate of candidates) {
++ if (!candidate) continue;
+ if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
+ candidate.focus({ preventScroll });
+ if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f126d37f26..8bab1dae9b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -62,6 +62,7 @@ overrides:
next-auth>nodemailer: ^9.0.3
patchedDependencies:
+ '@radix-ui/[email protected]': fb2bc2e96ad2c31dcb5860e509374a512fa08b1fade5805e3ae2dc72dcd68a0b
[email protected]: 298683aaa31566643f1899990a065b342ad777d8613f50a25ddc44dd46fb5b4d
importers:
@@ -15581,7 +15582,7 @@ snapshots:
- '@radix-ui/react-roving-focus': 1.1.11(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])
+ '@radix-ui/react-roving-focus': 1.1.11(patch_hash=fb2bc2e96ad2c31dcb5860e509374a512fa08b1fade5805e3ae2dc72dcd68a0b)(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])
'@radix-ui/react-slot': 1.2.3(@types/[email protected])([email protected])
'@radix-ui/react-use-callback-ref': 1.1.1(@types/[email protected])([email protected])
aria-hidden: 1.2.6
@@ -15689,7 +15690,7 @@ snapshots:
'@radix-ui/react-direction': 1.1.1(@types/[email protected])([email protected])
- '@radix-ui/react-roving-focus': 1.1.11(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])
+ '@radix-ui/react-roving-focus': 1.1.11(patch_hash=fb2bc2e96ad2c31dcb5860e509374a512fa08b1fade5805e3ae2dc72dcd68a0b)(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])
'@radix-ui/react-use-controllable-state': 1.2.2(@types/[email protected])([email protected])
'@radix-ui/react-use-previous': 1.1.1(@types/[email protected])([email protected])
'@radix-ui/react-use-size': 1.1.1(@types/[email protected])([email protected])
@@ -15699,7 +15700,7 @@ snapshots:
'@types/react': 19.2.14
'@types/react-dom': 19.2.3(@types/[email protected])
+ '@radix-ui/[email protected](patch_hash=fb2bc2e96ad2c31dcb5860e509374a512fa08b1fade5805e3ae2dc72dcd68a0b)(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':
dependencies:
'@radix-ui/primitive': 1.1.3
@@ -15827,7 +15828,7 @@ snapshots:
'@radix-ui/react-id': 1.1.1(@types/[email protected])([email protected])
- '@radix-ui/react-roving-focus': 1.1.11(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])
+ '@radix-ui/react-roving-focus': 1.1.11(patch_hash=fb2bc2e96ad2c31dcb5860e509374a512fa08b1fade5805e3ae2dc72dcd68a0b)(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])
'@radix-ui/react-use-controllable-state': 1.2.2(@types/[email protected])([email protected])
react: 19.2.4
react-dom: 19.2.4([email protected])
@@ -15841,7 +15842,7 @@ snapshots:
'@radix-ui/react-context': 1.1.2(@types/[email protected])([email protected])
'@radix-ui/react-direction': 1.1.1(@types/[email protected])([email protected])
- '@radix-ui/react-roving-focus': 1.1.11(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])
+ '@radix-ui/react-roving-focus': 1.1.11(patch_hash=fb2bc2e96ad2c31dcb5860e509374a512fa08b1fade5805e3ae2dc72dcd68a0b)(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])
'@radix-ui/react-use-controllable-state': 1.2.2(@types/[email protected])([email protected])
react: 19.2.4
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 700f4ce14e..728b219b30 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -104,6 +104,10 @@ overrides:
# Remove once next-auth allows nodemailer ^9.
"next-auth>nodemailer": "^9.0.3"
patchedDependencies:
+ # focusFirst crashes on null item refs (items unmounting while entry focus
+ # 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]
publicHoistPattern:
- "*prisma*"