Skip to content

feat(react-nav): add motion to components #34632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

marcosmoura
Copy link
Contributor

Previous Behavior

Components were opening and closing without any motion (static).

New Behavior

Components now have motion when opening and closing (smooth animations)

@marcosmoura marcosmoura self-assigned this Jun 11, 2025
@marcosmoura marcosmoura requested a review from a team as a code owner June 11, 2025 22:47
Copy link

Pull request demo site: URL

@marcosmoura marcosmoura requested a review from a team as a code owner June 11, 2025 23:02
@marcosmoura marcosmoura force-pushed the feat/react-nav/add-motion-to-components branch from ee2fdd6 to bfd97a8 Compare June 11, 2025 23:03
@marcosmoura marcosmoura removed the request for review from a team June 11, 2025 23:03
@marcosmoura marcosmoura enabled auto-merge (squash) June 11, 2025 23:03
@tudorpopams tudorpopams requested a review from dmytrokirpa June 11, 2025 23:13
"@fluentui/react-shared-contexts": "^9.23.1",
"@fluentui/react-tabster": "^9.24.8",
"@fluentui/react-theme": "^9.1.24",
"@fluentui/react-tooltip": "^9.6.9",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? It is not referenced in the PR, or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React tooltip is part of the Nav package for a long time. The diff here is simply putting the packages in alphabetical order.

@@ -12,7 +11,7 @@ import type { NavCategoryProps, NavCategoryState } from './NavCategory.types';
* @param props - props from this instance of NavCategory
* @param ref - reference to root HTMLDivElement of NavCategory
*/
export const useNavCategory_unstable = (props: NavCategoryProps, ref: React.Ref<HTMLDivElement>): NavCategoryState => {
export const useNavCategory_unstable = (props: NavCategoryProps): NavCategoryState => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason behind this change? Is it not used anywhere? If so, we need to cleanup a JSDoc above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true about the JSDoc. The issue here is that ref is never gonna be used, as the component is "renderless". We may need to keep it, to not change the component contract and add an eslint comment.

const getExpandIcon = (state: NavCategoryItemState) => {
assertSlots<NavCategoryItemSlots>(state);

if (state.expandIcon) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, but early returns might be a bit more readable:

if (!state.expandIcon) {
  return null
}

if (state.expandIconMotion) {
  return (
      <state.expandIconMotion>
        <state.expandIcon />
      </state.expandIconMotion>
  );
}

return <state.expandIcon />;

@@ -43,6 +71,7 @@ export const useNavCategoryItem_unstable = (
root: 'button',
icon: 'span',
expandIcon: 'span',
expandIconMotion: ExpandIconMotion as React.FC<PresenceMotionSlotProps>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typecasting might be redundant after React 18 PR support is merged

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. This was made before the merge. Gonna fix it!

import { NavDensity } from '../Nav/Nav.types';

export type NavSubItemGroupCollapseMotionParams = {
items?: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls add JSDoc description

import { useNavCategoryContext_unstable } from '../NavCategoryContext';
import {
PresenceMotionSlotProps,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PresenceMotionSlotProps,
type PresenceMotionSlotProps,


return {
open,
components: {
root: 'div',
collapseMotion: NavGroupMotion as React.FC<PresenceMotionSlotProps>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same as above, not sure if that still relevant

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

Successfully merging this pull request may close these issues.

2 participants