diff --git a/apps/app/src/components/ui/scroll-position-keeper.test.ts b/apps/app/src/components/ui/scroll-position-keeper.test.ts index 9874fe7dd21..65f296594b7 100644 --- a/apps/app/src/components/ui/scroll-position-keeper.test.ts +++ b/apps/app/src/components/ui/scroll-position-keeper.test.ts @@ -395,6 +395,32 @@ describe("ScrollPositionKeeper", () => { expect(timeline.layout.scrollTop).toBe(timeline.layout.maxScrollTop()); }); + it("follows a scroll without input while the pointer is over an embedded frame, whose wheel events the timeline never receives", () => { + const timeline = createTimeline(rowsOf(10), { attached: true }); + const frame = document.createElement("iframe"); + timeline.element("row-9").append(frame); + + frame.dispatchEvent(new MouseEvent("mouseover", { bubbles: true })); + timeline.layout.layoutScrollTo(timeline.layout.scrollTop - 300); + expect(timeline.keeper.isAttached()).toBe(false); + expect(timeline.layout.scrollTop).toBe( + timeline.layout.maxScrollTop() - 300, + ); + }); + + it("keeps the end again once a hovered frame leaves the timeline, even before the pointer moves", () => { + const timeline = createTimeline(rowsOf(10), { attached: true }); + const frame = document.createElement("iframe"); + timeline.element("row-9").append(frame); + + frame.dispatchEvent(new MouseEvent("mouseover", { bubbles: true })); + frame.remove(); + timeline.layout.layoutScrollTo(timeline.layout.scrollTop - 300); + + expect(timeline.keeper.isAttached()).toBe(true); + expect(timeline.layout.scrollTop).toBe(timeline.layout.maxScrollTop()); + }); + it("follows a focus move after Tab as the reader's scroll", () => { const timeline = createTimeline(rowsOf(10), { attached: true }); diff --git a/apps/app/src/components/ui/scroll-position-keeper.ts b/apps/app/src/components/ui/scroll-position-keeper.ts index 25834dabc83..53c6314eb1b 100644 --- a/apps/app/src/components/ui/scroll-position-keeper.ts +++ b/apps/app/src/components/ui/scroll-position-keeper.ts @@ -861,7 +861,8 @@ export class ScrollPositionKeeper { private followsUnexplainedScroll(): boolean { return ( this.windowFindOpen || - (this.position.kind !== "bottom" && this.pendingRestore === null) + (this.position.kind !== "bottom" && this.pendingRestore === null) || + this.options.getScrollElement()?.querySelector("iframe:hover") != null ); }