Skip to content

Conversation

robertpenner
Copy link
Collaborator

@robertpenner robertpenner commented Sep 9, 2025

MessageBarGroup

image

Previous Behavior

MessageBarGroup animations were implemented using react-transition-group and CSS.
• The animations did not respond to the OS animations toggle.

New Behavior

MessageBarGroup animations use motion components in a PresenceGroup.

  • The motion should look the same.
  • The motions now obey the OS animations setting. (This comes for free with the motion framework.)
  • Unused code is deleted or deprecated.
  • react-transition-group dependency is removed from all of v9! react-components is 7 kB smaller.
  • MessageBarTransition.tsx is deleted.
  • Unused styles are deleted. Unused properties and types for those styles are marked deprecated.

Testing Notes

• Test the animations in the MessageBar Animation example. (PR build)

image
• Click Add message to see messages enter; click the close button on a message to see it exit.
• When the radio button is both, the new message should enter with a fading slide, and exit with a fade.
• When the radio button is exit-only, the new message should enter without motion, and exit with a fade.
• When you disable animations in your OS setting, there should be no motions.

Related Issue(s)

Fixes #33470


History and Background

This PR re-applies the motion component refactoring from #33465, which was originally merged on December 20, 2024, but was later reverted in #34037 on March 19, 2025 due to a critical bug discovered in issue #33914.

What happened:

  1. Original Implementation (refactor(MessageBar): migrate slide & fade to motion components #33465): Successfully migrated MessageBar animations from react-transition-group to the modern motion components framework
  2. Bug Discovery ([Bug]: MessageBarGroup breaking change requires ref forwarding #33914): The change introduced a breaking change where MessageBarGroup required all children to support ref forwarding, causing applications to crash when non-ref-forwarding components were used
  3. Emergency Revert (Revert "refactor(MessageBar): migrate slide & fade to motion components (#33465)" #34037): The feature was reverted to restore stability for affected products including Outlook
  4. Motion Framework Fix (fix(react-motion): improve element validation to work with React 19 #34164): The underlying motion framework was improved to handle ref forwarding validation gracefully, logging warnings instead of crashing

How this PR addresses the original bug:

- Replace react-transition-group with @fluentui/react-motion components
- Use PresenceGroup and custom MessageBarMotion component
- Create custom fadeAtom and slideAtom motion definitions
- Remove MessageBarTransition.tsx and related CSS animations
- Add deprecation markers for unused properties
- Update to latest motion package versions (react-motion ^9.10.4, react-motion-components-preview ^0.10.0)
- Remove react-transition-group dependency

This restores the motion component refactoring from PR microsoft#33465,
which was reverted due to issue microsoft#33914. The underlying motion
framework bug has been fixed in PR microsoft#34164.
…idation tests

- Add ResizeObserver mock in jest setup for MessageBar component tests
- Required because MessageBar uses useMessageBarReflow which depends on ResizeObserver
- Add comprehensive tests for bug microsoft#33914 to validate motion components handle ref forwarding gracefully
- Tests confirm motion components now warn instead of crashing with invalid children
@robertpenner robertpenner requested a review from a team as a code owner September 9, 2025 19:18
@robertpenner robertpenner self-assigned this Sep 9, 2025
@robertpenner robertpenner changed the title refactor(MessageBar): migrate slide & fade to motion components (re-application) refactor(MessageBar): migrate slide & fade to motion components (redone) Sep 9, 2025
@robertpenner robertpenner changed the title refactor(MessageBar): migrate slide & fade to motion components (redone) refactor(react-message-bar-group): migrate slide & fade to motion components (redone) Sep 9, 2025
Copy link

github-actions bot commented Sep 9, 2025

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-components
react-components: entire library
1.284 MB
323.321 kB
1.276 MB
320.654 kB
-7.587 kB
-2.667 kB
react-message-bar
MessageBar (all components)
24.088 kB
8.96 kB
24.066 kB
8.955 kB
-22 B
-5 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: Button, FluentProvider & webLightTheme
68.796 kB
19.903 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
236.707 kB
68.531 kB
react-components
react-components: FluentProvider & webLightTheme
43.63 kB
14.257 kB
react-portal-compat
PortalCompatProvider
8.386 kB
2.624 kB
react-timepicker-compat
TimePicker
109.935 kB
36.335 kB
🤖 This report was generated against 7f60e73e38f099ea59b00138d1cc735729612263

@robertpenner robertpenner changed the title refactor(react-message-bar-group): migrate slide & fade to motion components (redone) refactor(react-message-bar): migrate slide & fade to motion components (redone) Sep 9, 2025
@robertpenner robertpenner changed the title refactor(react-message-bar): migrate slide & fade to motion components (redone) refactor(react-message-bar): migrate slide & fade to motion components (redo) Sep 9, 2025
Copy link

github-actions bot commented Sep 9, 2025

Pull request demo site: URL

@robertpenner robertpenner marked this pull request as draft September 9, 2025 19:26
@robertpenner robertpenner marked this pull request as ready for review September 9, 2025 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MessageBarGroup] Investigate fade + slide migration to motion components
1 participant