Skip to content

Commit 850993d

Browse files
fix: remove spacing from hidden elements + scroll indicator race (#1224)
* fix: remove spacing from hidden elements (#1141) Move the layout/padding wrapper div inside the conditional render chain so it only renders when the element is visible. Previously the outer div with py-2 padding persisted even when TimeConditionalRender, PositionConditionalRender, or ConditionsConditionalRender returned null, causing visible gaps. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: resolve scroll indicator race condition (#1225) Use wasAtBottomRef.current (continuously updated by scroll handler) as the primary check in the MutationObserver callback, falling back to the prevScrollHeight computation. This prevents the indicator from briefly appearing when a programmatic scroll and DOM mutation race — the scroll handler may have already registered "at bottom" even if prevScrollHeight is stale. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f365a19 commit 850993d

2 files changed

Lines changed: 19 additions & 17 deletions

File tree

client/src/Stage.jsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,27 +73,27 @@ export function Stage() {
7373
};
7474

7575
const renderElement = (element, index) => (
76-
<div
76+
<TimeConditionalRender
7777
key={`element_wrapper_${index}`}
78-
className={`mx-auto w-full px-4 py-2 ${layoutClassForElement(element)}`}
78+
displayTime={element.displayTime}
79+
hideTime={element.hideTime}
7980
>
80-
<TimeConditionalRender
81-
displayTime={element.displayTime}
82-
hideTime={element.hideTime}
81+
<PositionConditionalRender
82+
showToPositions={element.showToPositions}
83+
hideFromPositions={element.hideFromPositions}
8384
>
84-
<PositionConditionalRender
85-
showToPositions={element.showToPositions}
86-
hideFromPositions={element.hideFromPositions}
87-
>
88-
<ConditionsConditionalRender conditions={element.conditions}>
85+
<ConditionsConditionalRender conditions={element.conditions}>
86+
<div
87+
className={`mx-auto w-full px-4 py-2 ${layoutClassForElement(element)}`}
88+
>
8989
<Element
9090
element={element}
9191
onSubmit={() => player.stage.set("submit", true)}
9292
/>
93-
</ConditionsConditionalRender>
94-
</PositionConditionalRender>
95-
</TimeConditionalRender>
96-
</div>
93+
</div>
94+
</ConditionsConditionalRender>
95+
</PositionConditionalRender>
96+
</TimeConditionalRender>
9797
);
9898

9999
const renderDiscussionPage = () => (

client/src/components/scroll/useScrollAwareness.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ export function useScrollAwareness(containerRef, options = {}) {
7777
return;
7878
}
7979

80-
// Check if user WAS at bottom BEFORE content was added
81-
// We use prevScrollHeight because that's the height when user last scrolled
82-
const wasAtBottom = isAtBottom(
80+
// Check if user was at bottom before content was added.
81+
// Prefer the ref (continuously updated by scroll handler) over
82+
// recomputing from the cached prevScrollHeight, which can be
83+
// stale when a programmatic scroll and DOM mutation race.
84+
const wasAtBottom = wasAtBottomRef.current || isAtBottom(
8385
prevScrollHeight,
8486
scrollTop,
8587
container.clientHeight,

0 commit comments

Comments
 (0)