Skip to content

Commit eccd823

Browse files
spsauciersaucier-consultinggorhom
authored
fix(layout): correct isLayoutCalculated always returning true (#2642)(by @spsaucier)
* fix(layout): correct isLayoutCalculated always returning true The `isLayoutCalculated` derived value uses an OR condition to check whether `containerHeight` has been provided: if (containerHeight !== null || containerHeight !== undefined) This expression is always true for any value — if containerHeight is null, the `!== undefined` branch is true, and vice versa. The intended check should use AND: if (containerHeight !== null && containerHeight !== undefined) Without this fix, `isLayoutCalculated` returns true before layout measurements complete, allowing `evaluatePosition` to run with `containerHeight = INITIAL_LAYOUT_VALUE (-999)`. This produces incorrect detent positions and can cause the sheet's content panel to animate to an off-screen position while the backdrop renders correctly (since both are derived from the same animatedPosition, but the incorrect initial animation target can leave the body off-screen after the "completed" callback fires and the snap-point-change correction races with the mount animation). The second condition (`!== INITIAL_LAYOUT_VALUE`) still serves as the primary guard, but the first condition should be logically correct so it doesn't silently pass for null/undefined containerHeight values. * fix: merged container height logic to avoid early setting to true --------- Co-authored-by: Stephen Saucier <hulaman345@gmail.com> Co-authored-by: gorhom <gorhom.dev@gmail.com>
1 parent 02f3872 commit eccd823

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/components/bottomSheet/BottomSheet.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,12 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
225225
const isLayoutCalculated = useDerivedValue(() => {
226226
let isContainerHeightCalculated = false;
227227
const { containerHeight, handleHeight } = animatedLayoutState.get();
228-
//container height was provided.
229-
if (containerHeight !== null || containerHeight !== undefined) {
230-
isContainerHeightCalculated = true;
231-
}
232-
// container height did set.
233-
if (containerHeight !== INITIAL_LAYOUT_VALUE) {
228+
//container height was provided and set not to initial value
229+
if (
230+
containerHeight !== null &&
231+
containerHeight !== undefined &&
232+
containerHeight !== INITIAL_LAYOUT_VALUE
233+
) {
234234
isContainerHeightCalculated = true;
235235
}
236236

0 commit comments

Comments
 (0)