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

Aperta
#3,466 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
TypeScript
Stelle
845
Fork
295
Merge medio
1g 8h
PR unite (30g)
106

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di GetStream/stream-chat-react

Tutte le issue di GetStream/stream-chat-react

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.