Skip to content

Commit 3a505b2

Browse files
committed
fix(app): virtualizer getting wrong scroll root
1 parent 20f4337 commit 3a505b2

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

packages/ui/src/pierre/virtualizer.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,35 @@ export const virtualMetrics: Partial<VirtualFileMetrics> = {
1919
fileGap: 0,
2020
}
2121

22+
function scrollable(value: string) {
23+
return value === "auto" || value === "scroll" || value === "overlay"
24+
}
25+
26+
function scrollRoot(container: HTMLElement) {
27+
let node = container.parentElement
28+
while (node) {
29+
const style = getComputedStyle(node)
30+
if (scrollable(style.overflowY)) return node
31+
node = node.parentElement
32+
}
33+
}
34+
2235
function target(container: HTMLElement): Target | undefined {
2336
if (typeof document === "undefined") return
2437

25-
const root = container.closest("[data-component='session-review']")
26-
if (root instanceof HTMLElement) {
27-
const content = root.querySelector("[data-slot='session-review-container']")
38+
const review = container.closest("[data-component='session-review']")
39+
if (review instanceof HTMLElement) {
40+
const content = review.querySelector("[data-slot='session-review-container']")
41+
return {
42+
key: review,
43+
root: review,
44+
content: content instanceof HTMLElement ? content : undefined,
45+
}
46+
}
47+
48+
const root = scrollRoot(container)
49+
if (root) {
50+
const content = root.querySelector("[role='log']")
2851
return {
2952
key: root,
3053
root,

0 commit comments

Comments
 (0)