SuperChat Mention List Stays Open After the Composer Loses Focus

Aperta Adatta ai principianti
#795 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à
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend, testing

Direzione di ricerca

Inizia da src/components/Messaging/useMentionAutocomplete.tsx e dai gestori della textarea di ChatComposer; segui come l’hook apre e chiude il menu delle menzioni renderizzato in un portal. Trova i test del composer e copri la chiusura dell’elenco alla perdita del focus, la sua riapertura quando il focus torna su una @query incompleta e l’inserimento della menzione tramite selezione con il mouse. Il lavoro è completato quando questi casi passano e l’apertura del visualizzatore multimediale non lascia visibile alcun elenco di menzioni.

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

Descrizione

Overview

The @mention suggestion list in ChatComposer, which SuperChat and SuperChatInbox use, stays open after focus leaves the composer. Because the menu is portaled to document.body, it stays on screen over whatever comes next: a media viewer opened from the thread, or a different page in a host app that keeps the inbox mounted while it is hidden. The only way to dismiss it is to go back to the composer and press Escape or delete the @.

ECG rhythm strip Pasted Graphic 1 000000

Steps to Reproduce

In Storybook: SuperChat › Inbox › Playground

  1. Type @ in the composer. The participant list opens.
  2. Without choosing anyone, click an image in the thread to open the media viewer.
  3. The mention list stays open on top of the viewer.

In a host app that keeps the inbox mounted: TimeHuddle wraps its inbox page in React <Activity mode="hidden"> when another tab is showing.

  1. Type @ in the composer.
  2. Switch to another tab or page.
  3. The mention list is still on screen over the other page.

Current State

  • useMentionAutocomplete (src/components/Messaging/useMentionAutocomplete.tsx) closes the menu only on Escape, when an option is inserted, or when an edit removes the @ query.
  • Nothing closes it on textarea blur or on a pointer down outside the menu.
  • MentionMenu renders through createPortal(..., document.body). Hiding or covering the composer's subtree does not hide the menu. React <Activity mode="hidden">, for example, does not hide portaled content.

Proposed Changes

  1. Close the menu when the textarea blurs
    • Clear the active mention in the composer textarea's onBlur, for example through a close() that the hook returns.
    • Options already use onMouseDown with preventDefault(), so clicking an option keeps focus and still inserts it.
    • The textarea's onFocus or onSelect can call sync() again, so returning to an unfinished @query reopens the list.
  2. Test
    • Type @, blur the textarea, and expect chat-composer-mention-list to be gone.
    • Refocus with the caret after the @, and expect the list to reopen.
    • Clicking an option still inserts it.

Acceptance Criteria

  • The mention list closes when the composer textarea loses focus.
  • Choosing an option with the mouse still inserts the mention.
  • Focusing the composer again with an unfinished @query reopens the list.
  • In Storybook, opening the media viewer while the list is open leaves no list on screen.
  • A unit test covers closing on blur and reopening on focus.

Out of Scope (for Now)

  • Shared listbox keyboard navigation (#376).
  • Closing other portaled composer menus (the + add menu, send options), which already close on outside click through Dropdown.
  • Changing how a host hides the inbox.
Lingua principale
TypeScript
Stelle
2
Fork
7
Merge medio
1g 12h
PR unite (30g)
62

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 mieweb/ui

Tutte le issue di mieweb/ui

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.