[Bug]: MessageBar announces the title and body without a space between them
Maintainers usually reply within 2 days
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
- Domain
- accessibility, frontend
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
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_unstablebuilds the message frombodyRef.current?.textContent.MessageBarTitleseparates itself from the body only with generated content,'::after': { content: '" "' }inuseMessageBarTitleStyles.styles.ts. Generated content is not part oftextContent.- 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:
- Build the message in
useMessageBarBase_unstablefrom the title, the rest of the body and each action as separate parts, joined with a separator. - Give
MessageBarTitlea real text space in place of the::aftercontent.
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
- In an empty directory run
npm i @fluentui/[email protected] react@19 react-dom@19 jsdom. - Save
repro.cjsfrom the gist and runnode repro.cjs. App.jsxshows the first case through the public API withAriaLiveAnnouncer. 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
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/fluentui
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 2 days
-
[Bug]: Toaster throws in development when it has a style propPossibly taken @jakesalvesen claimed this 35 days ago. OpenComponent: Toast Fluent UI react-components (v9) Type: Bug :bug:
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
[Bug]: AriaLiveAnnouncer holds back a message announced in the commit that mounts itPossibly taken @dmytrokirpa claimed this 2 days ago. OpenArea: Accessibility Fluent UI react-components (v9) Type: Bug :bug:
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
microsoft/fluentui#37202 · 1 comment · 1 assignee ·
Maintainers usually reply within 2 days
-
[Bug]: fluent-radio-group ignores value changes while disabledPossibly taken @chrisdholt claimed this 1 day ago. OpenFluent UI WC (v3) web-components
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
microsoft/fluentui#37198 · 1 assignee ·
Maintainers usually reply within 2 days
-
[Bug]: Accordion crashes for scalar `defaultOpenItems={0}` (headless and styled v9)Possibly taken @arniebradfo claimed this 22 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
All issues in microsoft/fluentui
Similar issues
-
generate_image reference URL guard lets through IPv4-mapped IPv6 hosts and 100.64.0.0/10Possibly taken @goranai claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Inbox permission: an allow sent with `updatedInput` is ignored by Claude Code on its own safety checksPossibly taken @Raj1v claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
backnotprop/plannotator#4046 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
traPtitech/knoQ_R-UI#290 ·
Maintainers usually reply within 24 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
farion1231/cc-switch#9981 · 2 comments ·
Maintainers usually reply within 1 day
-
account bug course exam iris lecture
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day