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

Open Beginner friendly
#37,200 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@jakesalvesen is already working on this.

Since Nov 23, 2026.

  • #37201 by @jakesalvesen — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
react, typescript

Research direction

Start in useMessageBarBase_unstable, where the announced string is built from bodyRef.current?.textContent, and see how the actions list is appended as well; the space that sighted users see comes only from the ::after { content: ' ' } rule in useMessageBarTitleStyles.styles.ts, which textContent does not include. Pick one of the two approaches the reporter outlines (composing the message from title, body remainder and each action is the one that also fixes the actions), then update the 'TitleBody' and 'TitleBody,Action 1Action 2' expectations in MessageBar.test.tsx. Done means the announced string reads You're offline Keep working as usual. and actions are separated as Undo, View, with the existing MessageBar tests passing.

Written by the indexing model from the issue text.

Description

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.
Dominant language
TypeScript
Stars
20.4k
Forks
3k
Avg merge
3d 15h
Merged PRs (30d)
74

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/fluentui

All issues in microsoft/fluentui

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.