Skip to content

[Bug]: MessageBarGroup breaking change requires ref forwarding #33914

Closed

Description

Component

MessageBar

Package version

9.57.0

React version

18.2.0

Environment

This command does not work properly against our configuration: 
       
        "@fluentui/react": "^8.118.8",
        "@fluentui/react-brand-icons": "^1.0.133",
        "@fluentui/react-button": "^9.1.6",
        "@fluentui/react-calendar-compat": "^0.1.12",
        "@fluentui/react-card": "9.0.0-beta.34",
        "@fluentui/react-charting": "^5.17.1",
        "@fluentui/react-components": "^9.55.1",
        "@fluentui/react-datepicker-compat": "^0.4.42",
        "@fluentui/react-file-type-icons": "^8.6.0",
        "@fluentui/react-hooks": "^8.5.0",
        "@fluentui/react-icons": "^2.0.267",
        "@fluentui/react-link": "^9.1.10",
        "@fluentui/react-overflow": "^9.0.0-rc.2",
        "@fluentui/react-portal-compat": "^9.0.100",
        "@fluentui/react-positioning": "^9.9.21",
        "@fluentui/react-provider": "^9.1.5",
        "@fluentui/react-search": "^9.0.6",
        "@fluentui/react-shared-contexts": "^9.1.1",
        "@fluentui/react-tabster": "^9.14.6",
        "@fluentui/react-text": "9.1.8",
        "@fluentui/react-theme": "^9.1.1",
        "@fluentui/react-theme-sass": "^9.0.0-alpha.20",
        "@fluentui/react-timepicker-compat": "^0.2.20",
        "@fluentui/react-utilities": "^9.1.2",
        "@fluentui/react-window-provider": "^2.1.0",
        "@fluentui/style-utilities": "^8.6.0",
        "@fluentui/theme": "^2.4.11",
        "@fluentui/utilities": "^8.13.19",

        "react": "^18.2.0",
        "react-csv": "^2.0.3",
        "react-dom": "^18.2.0",
        "react-easy-crop": "^5.0.8",
        "react-horizontal-scrolling-menu": "0.7.10",
        "react-infinite-scroll-component": "^5.1.0",
        "react-inspector": "^2.2.2",
        "react-redux": "^7.1.0",
        "react-relay": "^18.1.0",
        "react-router": "^6.22.3",
        "react-router-dom": "^6.22.3",
        "react-transition-group": "^4.2.1",
        "react-virtualized-auto-sizer": "^1.0.6",
        "react-vtree": "^2.0.4",
        "react-webcam": "^7.1.1",
        "react-window": "^1.8.7",

Current Behavior

When using a MessageBargGroup component, the inclusion of react-motion requires that the child element accepts a ref. Passing an element that cannot forward a ref (such as an array of elements) will result in an application crash.

Expected Behavior

Do not throw in these cases.

Reproduction

https://stackblitz.com/edit/m3czge9y?file=src%2Fexample.tsx

Steps to reproduce

  1. Click on Add message button
  2. Observe the uncaught error in the console.

Are you reporting an Accessibility issue?

no

Suggested severity

Urgent - No workaround and Products/sites are affected

Products/sites affected

Outlook

Are you willing to submit a PR to fix?

no

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.

Activity

  1. added
    Shield: P1
    and removed on Feb 27, 2025
  2. smhigley commented on Mar 3, 2025

    @smhigley
    Contributor

    Walter Barrantes (@wbarrantes) do you have a more complete description of your use case? In the linked stackblitz, the issue could be easily solved with React.forwardRef, but I'm guessing the actual use case is more complex.

    The error is there because I believe react-motion does actually need a ref to work. Is there a reason to use MessageBargGroup at all, if you don't want the motion to work? As a control, it doesn't really do anything aside from providing animations to the child MessageBar components.

  3. wbarrantes commented on Mar 3, 2025

    @wbarrantes
    ContributorAuthor

    Hi Sarah Higley (@smhigley) | The Stackblitz example may not fully represent our situation in Outlook, which appears to be more complex. Although I am not an expert on the specific use case, it is important to note that a recent change involving the refactor(MessageBar): migrate slide & fade to motion components by robertpenner · Pull Request #33465 · microsoft/fluentui has caused an issue. The MessageBarGroup was updated to use motion components, resulting in a break in our application. As a result, this change needs to be either reverted or fixed.

    Currently, we have a pinned dependency in our package.json, which is preventing us from updating @fluentui/react-components to the latest version. Oleksandr Oleksandr Fediashov (@layershifter) mentioned there is a technique used previously for a similar issue with Dialog that might be applicable here: fix(Dialog): do not require ref forwarding by layershifter · Pull Request #32095 · microsoft/fluentui

    If resolving this fix will take some time, please consider reverting the change temporarily and then addressing the fix in a future version of react-components that accounts for cases where child elements do not support ref forwarding.

    Thank you!

  4. robertpenner commented on Sep 23, 2025

    @robertpenner
    Contributor

    Walter Barrantes (@wbarrantes) We have a PR to redo the MessageBarGroup motion migration without the breaking change, in PR #35168.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fluent UI react-components (v9)Package: motionShield: P1Status: In PRType: Bug 🐛

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions