From 7713f116709495c71edb3dc4322fede8ac9a9045 Mon Sep 17 00:00:00 2001 From: Erwan Leboucher Date: Thu, 30 Jul 2026 16:30:02 +0200 Subject: [PATCH 1/2] fix(mobile): stop pinned list sheet from jittering in height --- .../features/room/room-pin-menu/RoomPinMenu.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/features/room/room-pin-menu/RoomPinMenu.tsx b/src/app/features/room/room-pin-menu/RoomPinMenu.tsx index 514ac1088..d72411b2f 100644 --- a/src/app/features/room/room-pin-menu/RoomPinMenu.tsx +++ b/src/app/features/room/room-pin-menu/RoomPinMenu.tsx @@ -1,5 +1,5 @@ import type { MouseEventHandler, ReactNode } from 'react'; -import { forwardRef, useCallback, useMemo, useRef } from 'react'; +import { forwardRef, useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react'; import type { MatrixEvent, Room, RoomPinnedEventsEventContent } from '$types/matrix-sdk'; import { Box, @@ -210,6 +210,16 @@ export const RoomPinMenu = forwardRef( overscan: 4, }); + // Rows re-measure as dynamic content lands (decrypts, lazy media, replies), + // nudging the total size back and forth across the sheet's max height. The + // sheet sizes itself off this list, so latch the largest size seen: it may + // grow as content arrives, but never shrink and jitter while open. + const totalSize = virtualizer.getTotalSize(); + const [latchedSize, setLatchedSize] = useState(0); + useLayoutEffect(() => { + setLatchedSize((prev) => (totalSize > prev ? totalSize : prev)); + }, [totalSize]); + const renderMatrixEvent = useRoomMessagePreviewRenderer(room); const handleOpen = (roomId: string, eventId: string) => { @@ -237,7 +247,7 @@ export const RoomPinMenu = forwardRef( hideTrack visibility="Hover" style={{ - minHeight: 0, + minHeight: isMobile ? latchedSize : 0, flex: isMobile ? '0 1 auto' : 1, maxHeight: isMobile ? 'calc(85vh - 4rem)' : undefined, overflowY: 'auto', From 8f2d1688fcdd78e8d6d9e34f11f307daa01ba18a Mon Sep 17 00:00:00 2001 From: 7w1 Date: Thu, 30 Jul 2026 19:01:24 -0500 Subject: [PATCH 2/2] fix: clamp and reset pinned sheet height --- .../room/room-pin-menu/RoomPinMenu.tsx | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/app/features/room/room-pin-menu/RoomPinMenu.tsx b/src/app/features/room/room-pin-menu/RoomPinMenu.tsx index d72411b2f..0373e2ab7 100644 --- a/src/app/features/room/room-pin-menu/RoomPinMenu.tsx +++ b/src/app/features/room/room-pin-menu/RoomPinMenu.tsx @@ -212,13 +212,21 @@ export const RoomPinMenu = forwardRef( // Rows re-measure as dynamic content lands (decrypts, lazy media, replies), // nudging the total size back and forth across the sheet's max height. The - // sheet sizes itself off this list, so latch the largest size seen: it may - // grow as content arrives, but never shrink and jitter while open. + // sheet sizes itself off this list, so latch the largest size seen for the + // current set of pins. Structural changes rebase the latch so removals do + // not leave stale empty space. const totalSize = virtualizer.getTotalSize(); - const [latchedSize, setLatchedSize] = useState(0); + const pinListKey = JSON.stringify(sortedPinnedEvent); + const [latchedSize, setLatchedSize] = useState({ pinListKey, size: 0 }); useLayoutEffect(() => { - setLatchedSize((prev) => (totalSize > prev ? totalSize : prev)); - }, [totalSize]); + setLatchedSize((prev) => { + if (prev.pinListKey !== pinListKey) return { pinListKey, size: totalSize }; + if (totalSize <= prev.size) return prev; + return { pinListKey, size: totalSize }; + }); + }, [pinListKey, totalSize]); + const currentLatchedSize = latchedSize.pinListKey === pinListKey ? latchedSize.size : totalSize; + const mobileMaxHeight = 'calc(85vh - 4rem)'; const renderMatrixEvent = useRoomMessagePreviewRenderer(room); @@ -247,9 +255,9 @@ export const RoomPinMenu = forwardRef( hideTrack visibility="Hover" style={{ - minHeight: isMobile ? latchedSize : 0, + minHeight: isMobile ? `min(${currentLatchedSize}px, ${mobileMaxHeight})` : 0, flex: isMobile ? '0 1 auto' : 1, - maxHeight: isMobile ? 'calc(85vh - 4rem)' : undefined, + maxHeight: isMobile ? mobileMaxHeight : undefined, overflowY: 'auto', touchAction: 'pan-y', }}