GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): settings search reaches rows in collapsed sections (#18903) · Pipyakas/t3code@9dd4f8d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components/settings
    • settingsLayout.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/settings/settingsLayout.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/settings/settingsLayout.tsx
+57-4Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ function SettingsSearchTargetProvider({
8080
return <SettingsSearchTargetContext value={value}>{children}</SettingsSearchTargetContext>;
8181
}
8282

83+
let pendingTargetScroll: AbortController | undefined;
84+
8385
function scrollAndFocusSettingsTarget(target: HTMLElement, highlight = true): void {
86+
pendingTargetScroll?.abort();
8487
const prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
8588
const markedScrollTarget =
8689
typeof target.querySelector === "function"
@@ -92,10 +95,60 @@ function scrollAndFocusSettingsTarget(target: HTMLElement, highlight = true): vo
9295
? (target.firstElementChild as HTMLElement)
9396
: target);
9497

95-
scrollTarget.scrollIntoView({
96-
behavior: prefersReducedMotion ? "auto" : "smooth",
97-
block: "center",
98-
});
98+
const scroll = () =>
99+
scrollTarget.scrollIntoView({
100+
behavior: prefersReducedMotion ? "auto" : "smooth",
101+
block: "center",
102+
});
103+
scroll();
104+
const panel = target.parentElement?.closest<HTMLElement>(
105+
'[data-slot="collapsible-panel"][data-open]',
106+
);
107+
const heightTransition = () =>
108+
panel
109+
?.getAnimations()
110+
.find(
111+
(animation) =>
112+
animation instanceof CSSTransition && animation.transitionProperty === "height",
113+
);
114+
if (panel && (panel.hasAttribute("data-starting-style") || heightTransition())) {
115+
const controller = new AbortController();
116+
pendingTargetScroll = controller;
117+
const { signal } = controller;
118+
const finishScroll = () => {
119+
if (signal.aborted) return;
120+
controller.abort();
121+
if (
122+
panel.hasAttribute("data-open") &&
123+
target.isConnected &&
124+
document.activeElement === target
125+
) {
126+
scroll();
127+
}
128+
};
129+
const waitForHeight = () => {
130+
const transition = heightTransition();
131+
if (transition) {
132+
void transition.finished.then(finishScroll, () => controller.abort());
133+
} else {
134+
finishScroll();
135+
}
136+
};
137+
// Base UI clears the starting style before the height transition finishes.
138+
if (panel.hasAttribute("data-starting-style")) {
139+
const observer = new MutationObserver(() => {
140+
if (!panel.hasAttribute("data-starting-style")) {
141+
observer.disconnect();
142+
waitForHeight();
143+
}
144+
});
145+
observer.observe(panel, { attributes: true, attributeFilter: ["data-starting-style"] });
146+
signal.addEventListener("abort", () => observer.disconnect(), { once: true });
147+
} else {
148+
waitForHeight();
149+
}
150+
target.addEventListener("blur", () => controller.abort(), { once: true, signal });
151+
}
99152
target.focus({ preventScroll: true });
100153
target.classList.remove("settings-search-target-pulse");
101154
if (!highlight || prefersReducedMotion) return;

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.