[GH-ISSUE #3066] [Issue]: Composer emoji/GIF/sticker popovers have no viewport-height clamp, so on short/landscape phones the search box and top rows clip off the top of the screen #1633

Closed
opened 2026-10-21 05:41:08 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3066

Originally assigned to: @SpicyMarinara on GitHub.

What's wrong

The composer emoji/GIF/sticker popovers that open from the chat input bar use a fixed pixel height with no viewport-height clamp. On a short viewport — a phone in landscape, or a small phone whose on-screen keyboard / browser chrome has shrunk the visible height — the popover is taller than the screen. Because it is pinned by its bottom edge (just above the input bar) and grows upward, the overflow spills off the top of the screen. The search input and the first rows of results sit above the top edge and are unreachable: you can't search, and you can't scroll up to them because the panel itself doesn't scroll (only its inner result grid does, and the search box is pinned above it).

This affects the GIF picker, the sticker picker, and the emoji picker's composer mode. Notably, the emoji picker's other mode (the one anchored to a message reaction button) already clamps its height correctly — only the composer/GIF/sticker paths omit the clamp.

How to reproduce (try it yourself)

  1. Open the app on a phone and rotate to landscape (e.g. a 844×390 viewport — height 390px), or use DevTools device toolbar at 740×360.
  2. Open any chat and tap the GIF button in the input bar (or the emoji button in conversation mode, or the sticker button).
  3. Look at the top of the popover where the search field lives.

You'll see: the popover is ~352–416px tall but the screen is only ~360–390px tall, so the top of the panel — including the search input and the first row of GIFs/stickers/emoji — is pushed above the top edge of the screen and cannot be reached or scrolled to.
Expected: the popover should shrink to fit the available height (like the emoji reaction popover already does), keeping the search field and all rows on-screen with the results area scrolling internally.

Where it is

  • packages/client/src/components/ui/GifPicker.tsx:54-55 computes only a bottom (const refTop = barRect ? barRect.top : btnRect.top; const bottom = window.innerHeight - refTop + pad;) with no height clamp, and the panel at GifPicker.tsx:281 is className="fixed z-[9999] flex h-[26rem] w-96 max-w-[calc(100vw-1rem)] ..." with style={{ bottom: pos.bottom, ...(right/left) }} — fixed h-[26rem] (416px), no maxHeight.
  • packages/client/src/components/chat/StickerPicker.tsx:67-68 (same bottom-only positioning) and panel at StickerPicker.tsx:402 className="fixed z-[9999] flex h-[22rem] w-[21rem] ..." — fixed h-[22rem] (352px), no maxHeight.
  • packages/client/src/components/ui/EmojiPicker.tsx:1187-1199 — the composer branch (if (containerRef?.current) { ... setPos({ bottom, left }) / setPos({ bottom, right }); return; }) sets only bottom + horizontal, no maxHeight; the panel at EmojiPicker.tsx:1324 is fixed h-[22rem].

Done correctly (the contrasting sibling in the same file): EmojiPicker.tsx:1204 — the anchored branch computes const maxHeight = Math.min(pickerHeight, vh - 2 * pad); and the panel applies it at EmojiPicker.tsx:1330 via ...(pos.maxHeight != null ? { maxHeight: pos.maxHeight } : {}). The composer/GIF/sticker paths simply never compute or apply that clamp. (For contrast, conversation mode's inline mobile sheet at ConversationInput.tsx:1793 caps itself with max-h-[60vh], which is exactly the kind of clamp the portal pickers lack.)

What's happening

bottom = window.innerHeight - refTop + pad pins the panel's bottom just above the input bar, and the panel then occupies a fixed h-[22rem]/h-[26rem] upward from there. When window.innerHeight is smaller than that fixed height plus the input-bar offset, the panel's top edge computes to a negative coordinate (above the viewport). The panel has overflow-hidden and only its inner results list scrolls; the search field is a flex sibling pinned at the panel's (now off-screen) top, so it can't be reached. No @media/max-md: rule in globals.css constrains these panels' height — the mobile blocks there only touch scrollbars and input font-size — so nothing mitigates it.

Suggested fix

Apply the same viewport-height clamp the anchored emoji branch already uses, to all three composer popovers. In each positioning function, after computing bottom, also compute and store a maxHeight, then spread it into the panel style:

// where `bottom` is computed (GifPicker ~55, StickerPicker ~68, EmojiPicker composer ~1189):
const pad = 8;
const panelHeight = /* GifPicker: 416 (h-[26rem]); Sticker/Emoji: 352 (h-[22rem]) */;
const maxHeight = Math.min(panelHeight, window.innerHeight - 2 * pad);
setPos({ bottom, /* left | right */, maxHeight });
// panel style (add to the existing style object):
style={{
  bottom: pos.bottom,
  ...(pos.right != null ? { right: pos.right } : {}),
  ...(pos.left != null ? { left: pos.left } : {}),
  ...(pos.maxHeight != null ? { maxHeight: pos.maxHeight } : {}),
}}

EmojiPicker already has maxHeight in its pos type and panel style (line 1330), so the composer branch only needs to set it. GifPicker/StickerPicker need maxHeight added to their pos state shape and to the panel's style.

Regression avoided: on tall viewports (every phone in portrait, and desktop) window.innerHeight - 16 is larger than the fixed panel height, so maxHeight resolves to the panel's own height and nothing changes — the popovers look and behave exactly as today. The clamp only takes effect when the viewport is shorter than the panel, where it shrinks the panel to fit and lets the inner results grid scroll (the panels already use flex min-h-0 ... overflow-hidden internally, and the inner content lists already scroll, so the search field stays pinned at a now-on-screen top — identical to how the anchored emoji reaction popover already behaves). No z-index, horizontal position, or desktop layout is touched, and the change is confined to these three picker components (they portal to document.body with position: fixed, so no parent is affected).


AI-investigated against v2.0.6 (packages/client); cited lines read and confirmed. Mobile layout verified by reading the computed Tailwind classes + globals.css, not on a device — please confirm on a phone before fixing.

Originally created by @kolacheee on GitHub (Jun 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3066 Originally assigned to: @SpicyMarinara on GitHub. **What's wrong** The composer emoji/GIF/sticker popovers that open from the chat input bar use a **fixed pixel height with no viewport-height clamp**. On a short viewport — a phone in landscape, or a small phone whose on-screen keyboard / browser chrome has shrunk the visible height — the popover is taller than the screen. Because it is pinned by its *bottom* edge (just above the input bar) and grows upward, the overflow spills off the **top** of the screen. The search input and the first rows of results sit above the top edge and are unreachable: you can't search, and you can't scroll up to them because the panel itself doesn't scroll (only its inner result grid does, and the search box is pinned above it). This affects the GIF picker, the sticker picker, and the emoji picker's composer mode. Notably, the emoji picker's *other* mode (the one anchored to a message reaction button) already clamps its height correctly — only the composer/GIF/sticker paths omit the clamp. **How to reproduce (try it yourself)** 1. Open the app on a phone and rotate to **landscape** (e.g. a 844×390 viewport — height 390px), or use DevTools device toolbar at 740×360. 2. Open any chat and tap the GIF button in the input bar (or the emoji button in conversation mode, or the sticker button). 3. Look at the top of the popover where the search field lives. You'll see: the popover is ~352–416px tall but the screen is only ~360–390px tall, so the top of the panel — including the search input and the first row of GIFs/stickers/emoji — is pushed above the top edge of the screen and cannot be reached or scrolled to. Expected: the popover should shrink to fit the available height (like the emoji reaction popover already does), keeping the search field and all rows on-screen with the results area scrolling internally. **Where it is** - `packages/client/src/components/ui/GifPicker.tsx:54-55` computes only a `bottom` (`const refTop = barRect ? barRect.top : btnRect.top; const bottom = window.innerHeight - refTop + pad;`) with no height clamp, and the panel at `GifPicker.tsx:281` is `className="fixed z-[9999] flex h-[26rem] w-96 max-w-[calc(100vw-1rem)] ..."` with `style={{ bottom: pos.bottom, ...(right/left) }}` — fixed `h-[26rem]` (416px), no `maxHeight`. - `packages/client/src/components/chat/StickerPicker.tsx:67-68` (same `bottom`-only positioning) and panel at `StickerPicker.tsx:402` `className="fixed z-[9999] flex h-[22rem] w-[21rem] ..."` — fixed `h-[22rem]` (352px), no `maxHeight`. - `packages/client/src/components/ui/EmojiPicker.tsx:1187-1199` — the **composer** branch (`if (containerRef?.current) { ... setPos({ bottom, left }) / setPos({ bottom, right }); return; }`) sets only bottom + horizontal, no `maxHeight`; the panel at `EmojiPicker.tsx:1324` is fixed `h-[22rem]`. Done correctly (the contrasting sibling in the same file): `EmojiPicker.tsx:1204` — the **anchored** branch computes `const maxHeight = Math.min(pickerHeight, vh - 2 * pad);` and the panel applies it at `EmojiPicker.tsx:1330` via `...(pos.maxHeight != null ? { maxHeight: pos.maxHeight } : {})`. The composer/GIF/sticker paths simply never compute or apply that clamp. (For contrast, conversation mode's *inline* mobile sheet at `ConversationInput.tsx:1793` caps itself with `max-h-[60vh]`, which is exactly the kind of clamp the portal pickers lack.) **What's happening** `bottom = window.innerHeight - refTop + pad` pins the panel's bottom just above the input bar, and the panel then occupies a *fixed* `h-[22rem]`/`h-[26rem]` upward from there. When `window.innerHeight` is smaller than that fixed height plus the input-bar offset, the panel's top edge computes to a negative coordinate (above the viewport). The panel has `overflow-hidden` and only its inner results list scrolls; the search field is a flex sibling pinned at the panel's (now off-screen) top, so it can't be reached. No `@media`/`max-md:` rule in `globals.css` constrains these panels' height — the mobile blocks there only touch scrollbars and input font-size — so nothing mitigates it. **Suggested fix** Apply the same viewport-height clamp the anchored emoji branch already uses, to all three composer popovers. In each positioning function, after computing `bottom`, also compute and store a `maxHeight`, then spread it into the panel style: ```ts // where `bottom` is computed (GifPicker ~55, StickerPicker ~68, EmojiPicker composer ~1189): const pad = 8; const panelHeight = /* GifPicker: 416 (h-[26rem]); Sticker/Emoji: 352 (h-[22rem]) */; const maxHeight = Math.min(panelHeight, window.innerHeight - 2 * pad); setPos({ bottom, /* left | right */, maxHeight }); ``` ```tsx // panel style (add to the existing style object): style={{ bottom: pos.bottom, ...(pos.right != null ? { right: pos.right } : {}), ...(pos.left != null ? { left: pos.left } : {}), ...(pos.maxHeight != null ? { maxHeight: pos.maxHeight } : {}), }} ``` `EmojiPicker` already has `maxHeight` in its `pos` type and panel style (line 1330), so the composer branch only needs to set it. `GifPicker`/`StickerPicker` need `maxHeight` added to their `pos` state shape and to the panel's `style`. Regression avoided: on tall viewports (every phone in portrait, and desktop) `window.innerHeight - 16` is larger than the fixed panel height, so `maxHeight` resolves to the panel's own height and nothing changes — the popovers look and behave exactly as today. The clamp only takes effect when the viewport is shorter than the panel, where it shrinks the panel to fit and lets the inner results grid scroll (the panels already use `flex min-h-0 ... overflow-hidden` internally, and the inner content lists already scroll, so the search field stays pinned at a now-on-screen top — identical to how the anchored emoji reaction popover already behaves). No z-index, horizontal position, or desktop layout is touched, and the change is confined to these three picker components (they portal to `document.body` with `position: fixed`, so no parent is affected). --- *AI-investigated against v2.0.6 (packages/client); cited lines read and confirmed. Mobile layout verified by reading the computed Tailwind classes + globals.css, not on a device — please confirm on a phone before fixing.*
Author
Owner

@SpicyMarinara commented on GitHub (Jun 29, 2026):

Addressed in PR #3072 by commit 4146a380. Validated locally with pnpm check and pnpm smoke:ui.

<!-- gh-comment-id:4836257338 --> @SpicyMarinara commented on GitHub (Jun 29, 2026): Addressed in PR #3072 by commit 4146a380. Validated locally with pnpm check and pnpm smoke:ui.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1633
No description provided.