The best way to control Claude Code, Codex and more from any computer or phone
fix(web): project picker rows no longer jump when the palette opens (#37764)
Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Yash Singh committed
Nov 16, 2026 at 15:14 UTC
991c62d0d7cf2b29beca05e2fe56eb3227af4fae
3 files changed
+135
-5
apps/web/src/hooks/useLegendListRef.browser.test.tsx
+25
-1
@@ -1,6 +1,6 @@
1
import { LegendList, type LegendListRef } from "@legendapp/list/react";
2
import { createRef, useState, type RefObject } from "react";
3
-import { expect, it } from "vite-plus/test";
3
+import { expect, it, vi } from "vite-plus/test";
4
import { act, render } from "../../test/render";
5
import { useLegendListRef } from "./useLegendListRef";
6
@@ -30,6 +30,30 @@ function ListProbe({
30
);
31
}
32
33
+it("keeps rows at their layout height when they re-render while an ancestor is scaled", async () => {
34
+ const items = Array.from({ length: 6 }, (_, index) => `Row ${index}`);
35
+ // Dialogs and popovers scale in from 0.98; a re-render mid-animation must not record scaled sizes.
36
+ const list = (highlighted: string) => (
37
+ <div style={{ scale: "0.98" }}>
38
+ <LegendList
39
+ data={items}
40
+ extraData={highlighted}
41
+ keyExtractor={(item) => item}
42
+ renderItem={({ item }) => <div style={{ height: 40 }}>{item}</div>}
43
+ style={{ height: 300, width: 300 }}
44
+ />
45
+ </div>
46
+ );
47
+ await using screen = await render(list("Row 0"));
48
+ await expect.element(screen.getByText("Row 5")).toBeVisible();
49
+ await screen.rerender(list("Row 1"));
50
+ await vi.waitFor(() => {
51
+ const first = screen.getByText("Row 0").element().getBoundingClientRect();
52
+ const last = screen.getByText("Row 5").element().getBoundingClientRect();
53
+ expect((last.top - first.top) / 0.98).toBeCloseTo(200, 0);
54
+ });
55
+});
56
+
57
it("refreshes list edges after content shrinks without scrolling and after the list reopens", async () => {
58
const listRef = createRef<LegendListRef | null>();
59
const items = Array.from({ length: 20 }, (_, index) => `Row ${index}`);
patches/@legendapp__list@3.7.2.patch
+106
@@ -102,3 +102,109 @@ index 9ebfddc183a9b202d35c990a387c9b628feeb185..489050190144997ac72de8f4f7c62194
102
const ownsMeasuredItem = measurement.containerId === void 0 || isContainerItemCurrent(ctx, measurement.containerId, measurement.itemKey);
103
if (ownsMeasuredItem) {
104
const index = state.indexByKey.get(measurement.itemKey);
105
+diff --git a/react.js b/react.js
106
+index 515545471e08426fc90856256db9491db0ca4b92..b741735df1fbc0c954ed48f15590abce727d5336 100644
107
+--- a/react.js
108
++++ b/react.js
109
+@@ -5635,6 +5635,19 @@ function updateOneItemSize(ctx, itemKey, sizeObj, resolvedMeasurementItem, notif
110
+ }
111
+
112
+ // src/core/measureContainersInLayoutEffect.ts
113
++// T3 patch: measure rows by their layout box, as ResizeObserver does. getBoundingClientRect
114
++// includes ancestor transforms, so rows that mount while a dialog scales in measure short and
115
++// stay packed too tightly until they re-render.
116
++function measureContainerLayoutSize(element) {
117
++ const rect = element.getBoundingClientRect();
118
++ if (Math.abs(rect.width - element.offsetWidth) < 1 && Math.abs(rect.height - element.offsetHeight) < 1) {
119
++ return { height: rect.height, width: rect.width };
120
++ }
121
++ const style = getComputedStyle(element);
122
++ const height = Number.parseFloat(style.height);
123
++ const width = Number.parseFloat(style.width);
124
++ return Number.isFinite(height) && Number.isFinite(width) ? { height, width } : { height: rect.height, width: rect.width };
125
++}
126
+ function measureContainersInLayoutEffect(ctx, targetContainerIds = null) {
127
+ var _a3, _b, _c;
128
+ const dataChangeEpoch = ctx.state.dataChangeEpoch;
129
+@@ -5646,13 +5659,13 @@ function measureContainersInLayoutEffect(ctx, targetContainerIds = null) {
130
+ const element = viewRef == null ? void 0 : viewRef.current;
131
+ if (itemKey !== void 0 && element && isContainerItemCurrent(ctx, containerId, itemKey)) {
132
+ const generation = (_b = ctx.state.containerItemGenerations[containerId]) != null ? _b : 0;
133
+- const rect = element.getBoundingClientRect();
134
+- setContainerLayoutBaseline(element, rect);
135
++ const size = measureContainerLayoutSize(element);
136
++ setContainerLayoutBaseline(element, size);
137
+ measurements.push({
138
+ containerId,
139
+ generation,
140
+ itemKey,
141
+- size: { height: rect.height, width: rect.width }
142
++ size
143
+ });
144
+ }
145
+ }
146
+@@ -6296,9 +6309,8 @@ function processContainerLayout({ containerId, ctx, rectangle, ref, state }) {
147
+ var _a4;
148
+ if (state.itemKey === currentItemKey) {
149
+ const element = ref.current;
150
+- const rect = (_a4 = element == null ? void 0 : element.getBoundingClientRect) == null ? void 0 : _a4.call(element);
151
+- if (rect) {
152
+- layout = { height: rect.height, width: rect.width };
153
++ if (element) {
154
++ layout = measureContainerLayoutSize(element);
155
+ }
156
+ applyLayout();
157
+ }
158
+diff --git a/react.mjs b/react.mjs
159
+index ce08abe7ee62e8940f9c6ff169829244bd6bb736..fce79caef8387e517cbab8051b213cb57b1df590 100644
160
+--- a/react.mjs
161
++++ b/react.mjs
162
+@@ -5614,6 +5614,19 @@ function updateOneItemSize(ctx, itemKey, sizeObj, resolvedMeasurementItem, notif
163
+ }
164
+
165
+ // src/core/measureContainersInLayoutEffect.ts
166
++// T3 patch: measure rows by their layout box, as ResizeObserver does. getBoundingClientRect
167
++// includes ancestor transforms, so rows that mount while a dialog scales in measure short and
168
++// stay packed too tightly until they re-render.
169
++function measureContainerLayoutSize(element) {
170
++ const rect = element.getBoundingClientRect();
171
++ if (Math.abs(rect.width - element.offsetWidth) < 1 && Math.abs(rect.height - element.offsetHeight) < 1) {
172
++ return { height: rect.height, width: rect.width };
173
++ }
174
++ const style = getComputedStyle(element);
175
++ const height = Number.parseFloat(style.height);
176
++ const width = Number.parseFloat(style.width);
177
++ return Number.isFinite(height) && Number.isFinite(width) ? { height, width } : { height: rect.height, width: rect.width };
178
++}
179
+ function measureContainersInLayoutEffect(ctx, targetContainerIds = null) {
180
+ var _a3, _b, _c;
181
+ const dataChangeEpoch = ctx.state.dataChangeEpoch;
182
+@@ -5625,13 +5638,13 @@ function measureContainersInLayoutEffect(ctx, targetContainerIds = null) {
183
+ const element = viewRef == null ? void 0 : viewRef.current;
184
+ if (itemKey !== void 0 && element && isContainerItemCurrent(ctx, containerId, itemKey)) {
185
+ const generation = (_b = ctx.state.containerItemGenerations[containerId]) != null ? _b : 0;
186
+- const rect = element.getBoundingClientRect();
187
+- setContainerLayoutBaseline(element, rect);
188
++ const size = measureContainerLayoutSize(element);
189
++ setContainerLayoutBaseline(element, size);
190
+ measurements.push({
191
+ containerId,
192
+ generation,
193
+ itemKey,
194
+- size: { height: rect.height, width: rect.width }
195
++ size
196
+ });
197
+ }
198
+ }
199
+@@ -6275,9 +6288,8 @@ function processContainerLayout({ containerId, ctx, rectangle, ref, state }) {
200
+ var _a4;
201
+ if (state.itemKey === currentItemKey) {
202
+ const element = ref.current;
203
+- const rect = (_a4 = element == null ? void 0 : element.getBoundingClientRect) == null ? void 0 : _a4.call(element);
204
+- if (rect) {
205
+- layout = { height: rect.height, width: rect.width };
206
++ if (element) {
207
++ layout = measureContainerLayoutSize(element);
208
+ }
209
+ applyLayout();
210
+ }
pnpm-lock.yaml
+4
-4
@@ -370,7 +370,7 @@ patchedDependencies:
370
'@effect/vitest@4.1.2': 299510b71c36537a832a67e9d160a5f112a5f326a29e95c41cb45fc8234e47c7
371
'@expo/ui@58.0.27': 9f2547678939f4ec78fe45163b6455aad63d3c80353d7e0cc783f6a61a7ccc2f
372
'@ff-labs/fff-node@0.11.0': 93f62a76399b435a76588b2bef237db0a1e85880c1ac0d0759c416e9cc579252
373
- '@legendapp/list@3.7.2': 8f361e44c0756d883f8b8b5964f918f37b514a436c5058b773a1dc57eee5bfcc
373
+ '@legendapp/list@3.7.2': fc8470158c72676c35f43a0a84f90e53105c3eedd930e242534a37ff4159a3ef
374
'@muse-code/sdk@1.4.6': 7b495b607fc5d76b444c7c4d58821e839726a30e6f3c53564f0d59f2d5b42101
375
'@pierre/diffs@1.7.0-beta.4': 241563d810c29250e0e92f3eda74214393726d46667fedbf1f91a5f5bea07d1e
376
'@react-native-ai/apple@0.12.0': 2d09870c2848d185cb05b53ed823a46e12dba519324d8dd8e584e28731990f9d
@@ -567,7 +567,7 @@ importers:
567
version: 4.2.13
568
'@legendapp/list':
569
specifier: 3.7.2
570
- version: 3.7.2(patch_hash=8f361e44c0756d883f8b8b5964f918f37b514a436c5058b773a1dc57eee5bfcc)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
570
+ version: 3.7.2(patch_hash=fc8470158c72676c35f43a0a84f90e53105c3eedd930e242534a37ff4159a3ef)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
571
'@material/material-color-utilities':
572
specifier: 0.3.0
573
version: 0.3.0
@@ -1088,7 +1088,7 @@ importers:
1088
version: 5.3.0
1089
'@legendapp/list':
1090
specifier: 3.7.2
1091
- version: 3.7.2(patch_hash=8f361e44c0756d883f8b8b5964f918f37b514a436c5058b773a1dc57eee5bfcc)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
1091
+ version: 3.7.2(patch_hash=fc8470158c72676c35f43a0a84f90e53105c3eedd930e242534a37ff4159a3ef)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
1092
'@noble/hashes':
1093
specifier: 'catalog:'
1094
version: 1.8.0
@@ -15564,7 +15564,7 @@ snapshots:
15564
'@koromix/koffi-win32-x64@3.3.6':
15565
optional: true
15566
15567
- '@legendapp/list@3.7.2(patch_hash=8f361e44c0756d883f8b8b5964f918f37b514a436c5058b773a1dc57eee5bfcc)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)':
15567
+ '@legendapp/list@3.7.2(patch_hash=fc8470158c72676c35f43a0a84f90e53105c3eedd930e242534a37ff4159a3ef)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)':
15568
dependencies:
15569
react: 19.3.0
15570
use-sync-external-store: 1.7.0(react@19.3.0)