Skip to content
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

[BREAKING] feat(react-nav-preview): Allow controlled behavior for nav categories, add controlled example and other cleanup #32489

Merged
merged 26 commits into from
Sep 19, 2024

Conversation

mltejera
Copy link
Contributor

@mltejera mltejera commented Sep 9, 2024

Bug #32417 noted that there was no interface to control the open categories from initial load - so this PR adds that. I also took the opportunity to more thoroughly shake out the controlled scenario for the component.

Below was generated by Copilot:

This pull request introduces several changes to the @fluentui/react-nav-preview package, focusing on removing deprecated properties, adding new properties, and updating the navigation logic. The most important changes include the removal of the reserveSelectedNavItemSpace prop, the addition of defaultOpenCategories and openCategories props, and updates to the navigation context and event handling.

Breaking Changes:

  • Removed the reserveSelectedNavItemSpace prop from NavProps. (packages/react-components/react-nav-preview/library/etc/react-nav-preview.api.md, packages/react-components/react-nav-preview/library/src/components/Nav/Nav.types.ts, packages/react-components/react-nav-preview/library/src/components/NavContext.ts, packages/react-components/react-nav-preview/library/src/components/NavContext.types.ts) [1] [2] [3] [4]

New Features:

  • Added defaultOpenCategories and openCategories props to NavProps to manage the state of open categories. (packages/react-components/react-nav-preview/library/etc/react-nav-preview.api.md, packages/react-components/react-nav-preview/library/src/components/Nav/Nav.types.ts) [1] [2]
  • Introduced OnNavItemSelectData type for handling navigation item selection events. (packages/react-components/react-nav-preview/library/etc/react-nav-preview.api.md, packages/react-components/react-nav-preview/library/src/components/Nav/Nav.types.ts) [1] [2]

Enhancements:

  • Updated the icon selection logic for NavCategoryItem and added an example for the new props. (packages/react-components/react-nav-preview/library/src/components/NavCategoryItem/useNavCategoryItem.tsx)
  • Improved the useNav hook to handle the new defaultOpenCategories and openCategories props and updated the logic for toggling category items. (packages/react-components/react-nav-preview/library/src/components/Nav/useNav.ts) [1] [2] [3] [4]

Documentation:

  • Updated the documentation to reflect the changes in the NavProps and added descriptions for the new properties. (packages/react-components/react-nav-preview/library/etc/react-nav-preview.api.md, packages/react-components/react-nav-preview/library/src/components/Nav/Nav.types.ts) [1] [2]

These changes aim to improve the flexibility and functionality of the navigation component by removing deprecated features and adding new capabilities for managing open categories.

@fabricteam
Copy link
Collaborator

fabricteam commented Sep 9, 2024

📊 Bundle size report

✅ No changes found

@fabricteam
Copy link
Collaborator

fabricteam commented Sep 9, 2024

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 628 620 5000
Button mount 311 304 5000
Field mount 1130 1111 5000
FluentProvider mount 694 718 5000
FluentProviderWithTheme mount 78 90 10
FluentProviderWithTheme virtual-rerender 42 42 10
FluentProviderWithTheme virtual-rerender-with-unmount 76 80 10
MakeStyles mount 862 889 50000
Persona mount 1765 1689 5000
SpinButton mount 1400 1347 5000
SwatchPicker mount 1658 1623 5000

@mltejera mltejera marked this pull request as ready for review September 11, 2024 00:17
@mltejera mltejera requested review from a team as code owners September 11, 2024 00:17
@mltejera mltejera changed the title DRAFT: Controlled example and other cleanup Controlled example and other cleanup Sep 11, 2024
@sopranopillow sopranopillow changed the title Controlled example and other cleanup [BREAKING] feat(react-nav-preview): Allow controlled behavior for nav categories, add controlled example and other cleanup Sep 11, 2024
@mltejera mltejera force-pushed the nav/selected-bug-32417 branch from 21831b5 to a58d325 Compare September 16, 2024 22:59
Copy link
Contributor

@Mitch-At-Work Mitch-At-Work left a comment

Choose a reason for hiding this comment

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

One comment on ref update logic but otherwise looks good!

@mltejera mltejera force-pushed the nav/selected-bug-32417 branch from 3075b9b to f2752e9 Compare September 19, 2024 15:48
@mltejera mltejera merged commit 8506c11 into microsoft:master Sep 19, 2024
18 checks passed
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.

5 participants