[Bug]: MessageBar announces the title and body without a space between them

Aperta Adatta ai principianti
#37,200 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@jakesalvesen ci sta già lavorando.

Dal 23/11/2026.

  • #37201 di @jakesalvesen — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript

Direzione di ricerca

Inizia in useMessageBarBase_unstable, dove la stringa annunciata viene costruita da bodyRef.current?.textContent, e osserva come viene aggiunto anche l'elenco delle azioni; lo spazio che vedono gli utenti vedenti proviene solo dalla regola ::after { content: ' ' } in useMessageBarTitleStyles.styles.ts, che textContent non include. Scegli uno dei due approcci delineati da chi segnala il problema (comporre il messaggio da titolo, resto del body e ciascuna azione è quello che corregge anche le azioni), poi aggiorna le aspettative 'TitleBody' e 'TitleBody,Action 1Action 2' in MessageBar.test.tsx. Fatto significa che la stringa annunciata recita You're offline Keep working as usual. e che le azioni sono separate come Undo, View, con i test MessageBar esistenti che passano.

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

Descrizione

Fluent UI react-components (v9) Type: Bug :bug:
Component

MessageBar

Package version

9.75.2

React version

19.3.1

Environment
System:
    OS: Windows 11 10.0.26200
    CPU: 11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz
    Memory: 15.7 GB
  Binaries:
    Node: 26.13.1
    npm: 12.2.3
  npmPackages:
    @fluentui/react-components: 9.75.2 => 9.75.2
    @fluentui/react-message-bar: 9.7.9 => 9.7.9
    react: 19.3.1 => 19.3.1
    react-dom: 19.3.1 => 19.3.1
Current Behavior

When a MessageBar has a MessageBarTitle followed by body text, the message it announces has no space between the two.

<MessageBar>
  <MessageBarBody>
    <MessageBarTitle>You're offline</MessageBarTitle>
    Keep working as usual.
  </MessageBarBody>
</MessageBar>

announce is called with You're offlineKeep working as usual., and that is the text AriaLiveAnnouncer puts in its live region. The visible text has a space there, so the announcement joins two words that sighted users see apart.

The cause, on master:

  • useMessageBarBase_unstable builds the message from bodyRef.current?.textContent.
  • MessageBarTitle separates itself from the body only with generated content, '::after': { content: '" "' } in useMessageBarTitleStyles.styles.ts. Generated content is not part of textContent.
  • JSX drops the line break between </MessageBarTitle> and the body text, so there is no text space either. Every MessageBar story is written this way.

The actions are joined the same way. With two action buttons, Undo and View, the message ends in ,UndoView.

MessageBar.test.tsx currently expects the joined strings: 'TitleBody' and 'TitleBody,Action 1Action 2'.

Output of the script in the reproduction link, with @fluentui/[email protected]:

CASE 1 title and body
  announced: "You're offlineKeep working as usual."
CASE 2 title, body and two actions
  announced: "SavedYour changes are stored.,UndoView"
CASE 3 text space after the title (workaround)
  announced: "You're offline Keep working as usual."

I also checked it in a browser, with a Cypress component test on master (4f812d44, Electron 130). getComputedStyle(title, '::after').content is " ", the body's textContent is You're offlineKeep working as usual., and the live region of AriaLiveAnnouncer receives that same text.

Expected Behavior

The announced message keeps the word boundaries of the visible text:

  • You're offline Keep working as usual. for a title and a body.
  • A separator between the labels of the actions, for example Undo, View.

Two ways I can see to get there:

  1. Build the message in useMessageBarBase_unstable from the title, the rest of the body and each action as separate parts, joined with a separator.
  2. Give MessageBarTitle a real text space in place of the ::after content.

The first one keeps the DOM as it is today and also covers the actions.

Reproduction

https://gist.github.com/jakesalvesen/aa3c59dc073b94b0c011c67ba45028b7

Steps to reproduce
  1. In an empty directory run npm i @fluentui/[email protected] react@19 react-dom@19 jsdom.
  2. Save repro.cjs from the gist and run node repro.cjs.
  3. App.jsx shows the first case through the public API with AriaLiveAnnouncer. Click the button with a screen reader running.

The script renders three MessageBars inside an AnnounceProvider and prints the string each one passes to announce. The third one has a {' '} after the title, which is the workaround.

Are you reporting an Accessibility issue?

yes

Suggested severity

Medium - Has workaround

Products/sites affected

No response

Are you willing to submit a PR to fix?

yes

Validations
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
Lingua principale
TypeScript
Stelle
20.4k
Fork
3k
Merge medio
3g 15h
PR unite (30g)
74

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

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 microsoft/fluentui

Tutte le issue di microsoft/fluentui

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.