Skip to content

Commit 48fcf90

Browse files
fix(web): expanding stacked notices no longer scrolls a working thread (pingdotgg#20086)
Co-authored-by: Julius Marminge <[email protected]>
1 parent ee7f8dc commit 48fcf90

4 files changed

Lines changed: 48 additions & 3 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4668,11 +4668,22 @@ export default function ChatView(props: ChatViewProps) {
46684668
modelStrip.offsetHeight + Number.parseFloat(getComputedStyle(modelStrip).marginTop),
46694669
)
46704670
: 0;
4671+
const noticeStack = composerOverlayElement?.querySelector<HTMLElement>(
4672+
'[data-composer-banner-stack="true"]',
4673+
);
4674+
const expandedNoticesHeight = noticeStack
4675+
? Math.max(
4676+
0,
4677+
noticeStack.getBoundingClientRect().height -
4678+
Number.parseFloat(getComputedStyle(noticeStack).minHeight),
4679+
)
4680+
: 0;
46714681
const nextInset = resolveComposerTimelineInset({
46724682
currentInset: composerTimelineInsetRef.current,
4673-
overlayHeight: nextHeight,
4683+
overlayHeight: height,
46744684
isResting,
46754685
restingOnlyHeight,
4686+
expandedNoticesHeight,
46764687
});
46774688
if (composerTimelineInsetRef.current !== nextInset) {
46784689
composerTimelineInsetRef.current = nextInset;

‎apps/web/src/components/chat/ComposerBannerStack.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export function ComposerBannerStack({ className, items, attachedAbove }: Compose
121121
{hasStack ? (
122122
<div
123123
ref={noticesRef}
124+
data-composer-banner-stack="true"
124125
data-chat-composer-collapsed-controls="true"
125126
className={cn("relative z-20 min-h-3", stackExpanded && "z-50")}
126127
onPointerEnter={(event) => {

‎apps/web/src/components/composerFooterLayout.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,35 @@ describe("resolveComposerTimelineInset", () => {
140140
resolveComposerTimelineInset({ currentInset: 0, overlayHeight: 60, isResting: true }),
141141
).toBe(60 + COMPOSER_RESTING_EXPANSION_MIN_PX);
142142
});
143+
144+
it("keeps the timeline reservation stable through notice expansion and collapse", () => {
145+
const collapsed = resolveComposerTimelineInset({
146+
currentInset: 0,
147+
overlayHeight: 172,
148+
isResting: false,
149+
});
150+
const expanded = resolveComposerTimelineInset({
151+
currentInset: collapsed,
152+
overlayHeight: 532,
153+
isResting: false,
154+
expandedNoticesHeight: 360,
155+
});
156+
expect(expanded).toBe(collapsed);
157+
const resting = resolveComposerTimelineInset({
158+
currentInset: expanded,
159+
overlayHeight: 470,
160+
isResting: true,
161+
expandedNoticesHeight: 360,
162+
});
163+
expect(resting).toBe(collapsed);
164+
expect(
165+
resolveComposerTimelineInset({
166+
currentInset: resting,
167+
overlayHeight: 110,
168+
isResting: true,
169+
}),
170+
).toBe(collapsed);
171+
});
143172
});
144173

145174
describe("shouldUseRestingComposerLayout", () => {

‎apps/web/src/components/composerFooterLayout.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,20 @@ export function resolveComposerTimelineInset(input: {
5959
overlayHeight: number;
6060
isResting: boolean;
6161
restingOnlyHeight?: number;
62+
expandedNoticesHeight?: number;
6263
}): number {
64+
// Expanded notices temporarily cover the timeline. Remove their growth before
65+
// rounding so fractional measurements reserve exactly the collapsed height.
66+
const overlayHeight = Math.ceil(input.overlayHeight - (input.expandedNoticesHeight ?? 0));
6367
return input.isResting
6468
? Math.max(
6569
input.currentInset,
66-
input.overlayHeight +
70+
overlayHeight +
6771
(input.currentInset === 0
6872
? COMPOSER_RESTING_EXPANSION_MIN_PX - (input.restingOnlyHeight ?? 0)
6973
: 0),
7074
)
71-
: input.overlayHeight;
75+
: overlayHeight;
7276
}
7377

7478
export function overlayComposerIsResting(input: {

0 commit comments

Comments
 (0)