Skip to content

fix(react-headless-components-preview): add state data attributes - #36712

Open
Dmytro Kirpa (dmytrokirpa) wants to merge 7 commits into
microsoft:masterfrom
dmytrokirpa:dmytrokirpa-effective-giggle
Open

fix(react-headless-components-preview): add state data attributes#36712
Dmytro Kirpa (dmytrokirpa) wants to merge 7 commits into
microsoft:masterfrom
dmytrokirpa:dmytrokirpa-effective-giggle

Conversation

@dmytrokirpa

Copy link
Copy Markdown
Contributor

Previous Behavior

The headless Nav components did not expose several resolved interaction states as data-* attributes. AvatarGroup context providers could also drop an ambient size value when relaying context.

New Behavior

NavDrawer, NavCategoryItem, NavItem, and NavSubItem now emit and type their resolved state attributes for styling and selectors. AvatarGroup context hooks preserve ambient size context without adding size props or state to headless components. Focused tests cover the new true, false, and default states.

Related Issue(s)

  • N/A

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-headless-components-preview
react-headless-components-preview: entire library
241.736 kB
68.14 kB
242.029 kB
68.213 kB
293 B
73 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-headless-components-preview
@fluentui/react-headless-components-preview/tag-picker
54.012 kB
17.756 kB
react-headless-components-preview
@fluentui/react-headless-components-preview/teaching-popover
36.073 kB
12.006 kB
🤖 This report was generated against f51ba35768877b1e01346ac76e3ad4af7689a5eb

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

AvatarGroup size forwarding remains incorrect, and removing data-open introduces an undocumented compatibility break.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds resolved data-* state attributes to headless Nav components and adjusts AvatarGroup context forwarding.

Changes:

  • Adds disabled, expanded, selected, and drawer-type attributes with tests.
  • Updates public Nav API declarations.
  • Reuses styled AvatarGroup context hooks and adds a patch change file.
File summaries
File Description
NavSubItem/useNavSubItem.ts Adds data-disabled.
NavSubItem/NavSubItem.types.ts Types the attribute.
NavSubItem/NavSubItem.test.tsx Tests disabled states.
NavItem/useNavItem.ts Adds data-disabled.
NavItem/NavItem.types.ts Types the attribute.
NavItem/NavItem.test.tsx Tests disabled states.
NavDrawer/useNavDrawer.ts Adds resolved data-type.
NavDrawer/NavDrawer.types.ts Types drawer state.
NavDrawer/NavDrawer.test.tsx Tests drawer types.
NavCategoryItem/useNavCategoryItem.ts Adds disabled/expanded states.
NavCategoryItem/NavCategoryItem.types.ts Updates state attributes.
NavCategoryItem/NavCategoryItem.test.tsx Tests category states.
Nav/Nav.test.tsx Updates expanded-state assertions.
AvatarGroup/useAvatarGroupContextValues.ts Delegates group context construction.
AvatarGroupPopover/useAvatarGroupPopoverContextValues.ts Delegates overflow context construction.
library/etc/nav.api.md Updates generated API declarations.
change/*.json Records a patch release.
Review details
  • Files reviewed: 17/17 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +13 to +15
export const useAvatarGroupPopoverContextValues = useAvatarGroupPopoverContextValues_unstable as unknown as (
state: AvatarGroupPopoverState,
) => AvatarGroupContextValues;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is intentional: consumers may need to access the size context at runtime, even though this value is excluded from the types by default.

Comment on lines +11 to +13
export const useAvatarGroupContextValues = useAvatarGroupContextValues_unstable as (
state: AvatarGroupState,
) => AvatarGroupContextValues;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same as above


state.root['data-open'] = toDataAttributeValue(state.open);
state.root['data-disabled'] = toDataAttributeValue(state.root.disabled || state.root['aria-disabled']);
state.root['data-expanded'] = toDataAttributeValue(state.open);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copilot revert the data-open to data-exanded change and update the API snapshot

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Pull request demo site: URL

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The patch still breaks the existing data-open contract and omits required Storybook documentation for the new attributes.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

packages/react-components/react-headless-components-preview/library/src/components/Nav/NavCategoryItem/useNavCategoryItem.ts:67

  • The requested compatibility revert is still missing: this removes the existing public data-open state/DOM attribute in favor of data-expanded. The headless contract explicitly classifies attribute removal/rename as breaking (docs/react-v9/contributing/rfcs/react-components/convergence/headless-components.md:174), while this PR ships a patch. Restore data-open in the hook, state/API types, and tests; if data-expanded is also retained, emit its documented boolean values ("true"/"false") rather than presence/absence.
  state.root['data-expanded'] = toDataAttributeValue(state.open);
  • Files reviewed: 17/17 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment on lines +24 to +27
/**
* Data attribute reflecting the resolved Drawer type ('inline' or 'overlay').
*/
'data-type'?: 'inline' | 'overlay';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

data attributes will be documented separately similarly to what we have for public props

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