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

Đang mở Phù hợp với người mới
#37,200 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@jakesalvesen đang làm issue này rồi.

Từ ngày 23/11/2026.

  • #37201 của @jakesalvesen — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
74/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react, typescript
Lĩnh vực
accessibility, frontend

Hướng nghiên cứu

Bắt đầu trong useMessageBarBase_unstable, nơi chuỗi được thông báo được tạo từ bodyRef.current?.textContent, và xem cách danh sách hành động cũng được thêm vào; khoảng trắng mà người dùng có thị lực nhìn thấy chỉ đến từ quy tắc ::after { content: ' ' } trong useMessageBarTitleStyles.styles.ts, mà textContent không bao gồm. Chọn một trong hai cách tiếp cận mà người báo lỗi phác thảo (tổ hợp thông điệp từ tiêu đề, phần còn lại của body và từng hành động là cách cũng sửa các hành động), sau đó cập nhật các kỳ vọng 'TitleBody' và 'TitleBody,Action 1Action 2' trong MessageBar.test.tsx. Hoàn tất nghĩa là chuỗi được thông báo đọc là You're offline Keep working as usual. và các hành động được phân tách như Undo, View, với các bài kiểm thử MessageBar hiện có đều vượt qua.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
20.4k
Fork
3k
Merge trung bình
3 ngày 15 giờ
Pull request đã merge (30 ngày)
74

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/fluentui

Tất cả issue của microsoft/fluentui

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.