The best way to control Claude Code, Codex and more from any computer or phone
fix(web): settings search reaches rows in collapsed sections (#18903)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Guillermo Casanova committed
Oct 19, 2026 at 20:18 UTC
afa42e6c2df3124593cadbff04b61f4d1ee6848d
2 files changed
+150
-4
apps/web/src/components/settings/settingsLayout.browser.test.tsx
+93
@@ -62,6 +62,99 @@ describe("settings search targets", () => {
62
expect(target.classList.contains(PULSE)).toBe(false);
63
});
64
65
+ it.each(["before", "after", "without animation"] as const)(
66
+ "fully reveals the row when the opening style clears: %s",
67
+ async (phase) => {
68
+ // Keep scrolling synchronous while the panel height transitions independently.
69
+ reduceMotion(true);
70
+ document.body.innerHTML = `
71
+ <div id="viewport" style="height: 200px; overflow: auto; overflow-anchor: none">
72
+ <div id="panel" data-slot="collapsible-panel" data-open data-starting-style
73
+ style="height: 0; overflow: hidden; transition: height 200ms linear">
74
+ <div style="height: 500px"></div>
75
+ <div id="legacy-sidebar" tabindex="-1" style="height: 40px">Legacy sidebar</div>
76
+ <div style="height: 60px"></div>
77
+ </div>
78
+ </div>`;
79
+ const viewport = document.getElementById("viewport")!;
80
+ const panel = document.getElementById("panel")!;
81
+ const target = document.getElementById("legacy-sidebar")!;
82
+
83
+ void panel.offsetHeight;
84
+ const animated = phase !== "without animation";
85
+ if (animated) {
86
+ panel.style.height = "600px";
87
+ } else {
88
+ panel.style.transition = "none";
89
+ }
90
+ const transition = panel.getAnimations()[0];
91
+ if (animated) {
92
+ expect(transition).toBeDefined();
93
+ transition!.pause();
94
+ transition!.currentTime = phase === "before" ? 0 : 100;
95
+ if (phase === "after") panel.removeAttribute("data-starting-style");
96
+ }
97
+
98
+ expect(scrollToSettingsTarget("legacy-sidebar")).toBe(true);
99
+ expect(document.activeElement).toBe(target);
100
+ const opened = animated
101
+ ? new Promise<void>((resolve) => {
102
+ panel.addEventListener("transitionend", () => resolve(), { once: true });
103
+ })
104
+ : Promise.resolve();
105
+ panel.style.height = "600px";
106
+ panel.removeAttribute("data-starting-style");
107
+ transition?.finish();
108
+ await opened;
109
+
110
+ const bounds = viewport.getBoundingClientRect();
111
+ const row = target.getBoundingClientRect();
112
+ expect(row.top).toBeGreaterThanOrEqual(bounds.top);
113
+ expect(row.bottom).toBeLessThanOrEqual(bounds.bottom);
114
+ expect(document.activeElement).toBe(target);
115
+ },
116
+ );
117
+
118
+ it("keeps the newer search destination visible when an earlier panel finishes opening", async () => {
119
+ reduceMotion(true);
120
+ document.body.innerHTML = `
121
+ <div id="viewport" style="height: 200px; overflow: auto; overflow-anchor: none">
122
+ <div id="new-target" tabindex="-1" style="height: 40px">New target</div>
123
+ <div style="height: 1000px"></div>
124
+ <div id="panel" data-slot="collapsible-panel" data-open data-starting-style
125
+ style="height: 0; overflow: hidden; transition: height 200ms linear">
126
+ <div style="height: 500px"></div>
127
+ <div id="legacy-sidebar" tabindex="-1" style="height: 40px">Legacy sidebar</div>
128
+ <div style="height: 60px"></div>
129
+ </div>
130
+ </div>`;
131
+ const panel = document.getElementById("panel")!;
132
+ void panel.offsetHeight;
133
+ panel.style.height = "600px";
134
+ const transition = panel.getAnimations()[0]!;
135
+ transition.pause();
136
+ transition.currentTime = 100;
137
+
138
+ scrollToSettingsTarget("legacy-sidebar");
139
+ panel.removeAttribute("data-starting-style");
140
+ scrollToSettingsTarget("new-target");
141
+ const opened = new Promise<void>((resolve) => {
142
+ panel.addEventListener("transitionend", () => resolve(), { once: true });
143
+ });
144
+ transition.finish();
145
+ await opened;
146
+
147
+ const viewport = document.getElementById("viewport")!;
148
+ const target = document.getElementById("new-target")!;
149
+ expect(target.getBoundingClientRect().top).toBeGreaterThanOrEqual(
150
+ viewport.getBoundingClientRect().top,
151
+ );
152
+ expect(target.getBoundingClientRect().bottom).toBeLessThanOrEqual(
153
+ viewport.getBoundingClientRect().bottom,
154
+ );
155
+ expect(document.activeElement).toBe(target);
156
+ });
157
+
158
it("leaves not-yet-mounted destinations to their mount lifecycle", () => {
159
expect(scrollToSettingsTarget("archive")).toBe(false);
160
});
apps/web/src/components/settings/settingsLayout.tsx
+57
-4
@@ -75,7 +75,10 @@ function SettingsSearchTargetProvider({
75
return <SettingsSearchTargetContext value={value}>{children}</SettingsSearchTargetContext>;
76
}
77
78
+let pendingTargetScroll: AbortController | undefined;
79
+
80
function scrollAndFocusSettingsTarget(target: HTMLElement, highlight = true): void {
81
+ pendingTargetScroll?.abort();
82
const prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
83
const markedScrollTarget =
84
typeof target.querySelector === "function"
@@ -87,10 +90,60 @@ function scrollAndFocusSettingsTarget(target: HTMLElement, highlight = true): vo
90
? (target.firstElementChild as HTMLElement)
91
: target);
92
90
- scrollTarget.scrollIntoView({
91
- behavior: prefersReducedMotion ? "auto" : "smooth",
92
- block: "center",
93
- });
93
+ const scroll = () =>
94
+ scrollTarget.scrollIntoView({
95
+ behavior: prefersReducedMotion ? "auto" : "smooth",
96
+ block: "center",
97
+ });
98
+ scroll();
99
+ const panel = target.parentElement?.closest<HTMLElement>(
100
+ '[data-slot="collapsible-panel"][data-open]',
101
+ );
102
+ const heightTransition = () =>
103
+ panel
104
+ ?.getAnimations()
105
+ .find(
106
+ (animation) =>
107
+ animation instanceof CSSTransition && animation.transitionProperty === "height",
108
+ );
109
+ if (panel && (panel.hasAttribute("data-starting-style") || heightTransition())) {
110
+ const controller = new AbortController();
111
+ pendingTargetScroll = controller;
112
+ const { signal } = controller;
113
+ const finishScroll = () => {
114
+ if (signal.aborted) return;
115
+ controller.abort();
116
+ if (
117
+ panel.hasAttribute("data-open") &&
118
+ target.isConnected &&
119
+ document.activeElement === target
120
+ ) {
121
+ scroll();
122
+ }
123
+ };
124
+ const waitForHeight = () => {
125
+ const transition = heightTransition();
126
+ if (transition) {
127
+ void transition.finished.then(finishScroll, () => controller.abort());
128
+ } else {
129
+ finishScroll();
130
+ }
131
+ };
132
+ // Base UI clears the starting style before the height transition finishes.
133
+ if (panel.hasAttribute("data-starting-style")) {
134
+ const observer = new MutationObserver(() => {
135
+ if (!panel.hasAttribute("data-starting-style")) {
136
+ observer.disconnect();
137
+ waitForHeight();
138
+ }
139
+ });
140
+ observer.observe(panel, { attributes: true, attributeFilter: ["data-starting-style"] });
141
+ signal.addEventListener("abort", () => observer.disconnect(), { once: true });
142
+ } else {
143
+ waitForHeight();
144
+ }
145
+ target.addEventListener("blur", () => controller.abort(), { once: true, signal });
146
+ }
147
target.focus({ preventScroll: true });
148
target.classList.remove("settings-search-target-pulse");
149
if (!highlight || prefersReducedMotion) return;