bug: Reaction popups are cut off by the channel header or composer (DialogAnchor can't use `fitAvailableSpace`)

未關閉
#3,466 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
62/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
react, typescript
領域
frontend

研究方向

Start in src/components/Dialog/service/DialogAnchor.tsx and useDialogAnchor, where fitAvailableSpace needs to be accepted and passed to usePopoverPosition, which already supports it for Dropdown. Then check MessageReactions and ReactionSelectorWithButton so they pass the option through. In the ResizeObserver callback, defer update with requestAnimationFrame and cancel it on cleanup to avoid the loop warning. Done when the reaction popups cap their height to the available space and scroll, with no ResizeObserver loop error in the console.

由索引模型根據 Issue 內容生成。

描述

Describe the bug

The reaction popups open through DialogAnchor: the list of who reacted (MessageReactions), and the reaction selector with its "+" list of every emoji (ReactionSelectorWithButton). When one is taller than the space on both sides of the message, floating-ui flips it to the roomier side, but it still overflows. The channel header or the composer then covers part of it.

usePopoverPosition already supports fitAvailableSpace, which caps the floating element's height to the space available. Only Dropdown uses it today. DialogAnchor and useDialogAnchor don't accept or pass it through, so the reaction popups can't use it.

A second problem shows up once it's turned on. With updatePositionOnContentResize, useDialogAnchor calls update directly inside its ResizeObserver callback. Fitting the dialog resizes it again during that same callback, and the browser logs "ResizeObserver loop completed with undelivered notifications".

To Reproduce

  1. Open a channel in a short window, for example about 600px tall.
  2. On a message near the middle of the list, open the reaction selector and expand the full emoji list with "+". Or open the reactions detail on a message with many reactions.
  3. The popup extends under the channel header or the composer.

Expected behavior

The popup's height is capped to the space on the side it opens toward, and its content scrolls.

Suggested fix

We've patched the built ES output. We can open a PR against the source, with a test, if you'd like:

  1. Add fitAvailableSpace to DialogAnchor's props and to useDialogAnchor, and pass it to usePopoverPosition.
  2. Pass fitAvailableSpace from MessageReactions and ReactionSelectorWithButton.
  3. In the ResizeObserver callback, defer update to the next animation frame, and cancel that frame on cleanup:
let frame = 0;
const resizeObserver = new ResizeObserver(() => {
  cancelAnimationFrame(frame);
  frame = requestAnimationFrame(update);
});
resizeObserver.observe(popperElement);
return () => {
  cancelAnimationFrame(frame);
  resizeObserver.disconnect();
};

Our workaround

The patch described above, applied to dist/es and the types with pnpm's patchedDependencies.

Package version

  • stream-chat-react: 15.0.0. The same code is in 15.0.2, checked in source (src/components/Dialog/service/DialogAnchor.tsx).
  • stream-chat-js: 10.0.1

Desktop

  • Chrome on macOS

Additional context

App id: 67855

主要語言
TypeScript
星號
845
分支
295
平均合併
1 天 8 小時
30 天內合併 PR
106

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

GetStream/stream-chat-react 的其他 Issue

查看 GetStream/stream-chat-react 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。