fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

[Bug]: Legends overflow menu warns "You are using both MenuList and Menu props" every time it opens

Open jakesalvesen opened this issue 1 month ago • 1 comments

Charting Control

Legends

Package version

@fluentui/[email protected] (also present on master at 9c0797a)

React version

19.3.1

Environment

System:
  OS: Windows 11 10.0.26300
  CPU: (24) x64 AMD Ryzen 9 7900X 12-Core Processor
  Memory: 12.84 GB / 31.16 GB
Browsers:
  Chrome: 155.0.8059.85
  Edge: Chromium
npmPackages:
  @fluentui/react-charts: 9.3.28
  react: 19.3.1
  react-dom: 19.3.1
  @types/react: 19.3.0

Current Behavior

Opening the Legends overflow menu logs this warning once per open, in development builds:

You are using both MenuList and Menu props, we recommend you to use Menu props when available

The overflow UI itself is correct. With 12 legends in a 220px container the trigger renders "+11 more" and the menu renders 11 matching rows, so only the warning is wrong.

Cause: OverflowMenu passes checkedValues to MenuList inside a Menu that owns the selection context. https://github.com/microsoft/fluentui/blob/master/packages/charts/react-charts/library/src/components/Legends/OverflowMenu.tsx

useMenuList_unstable calls usingPropsAndMenuContext, which iterates every key in the always-present Menu context and warns when a MenuList prop shares a key. checkedValues is always part of that context, so passing it to MenuList inside a Menu warns every time the popover mounts.

This is a follow-up to #36641 and #36691. The stale-count crash from those is fixed and verified on 9.3.28 (the label always equals the rendered row count); this is the remaining issue in the same component.

Expected Behavior

No warning. Passing the controlled selection to Menu is the pattern the warning recommends, and MenuList then reads it from context:

...

Selection, aria-checked, aria-setsize, and aria-posinset must stay identical. The regression check is a test that opens the overflow menu in the existing Legends.test.tsx harness and asserts no "both MenuList and Menu props" warning; I will include it in the fix PR.

Reproduction

https://gist.github.com/jakesalvesen/d768ff90ebbbb1ecbf30cc5dbcbd6d6c - drop-in test for the existing Legends.test.tsx overflow harness; it fails on master and passes with the fix, and will be part of the fix PR.

Steps to reproduce

  1. Render Legends with 12 items inside a 220px-wide container so the overflow trigger appears.
  2. Click the "+11 more" trigger to open the overflow menu.
  3. Observe the console warning "You are using both MenuList and Menu props, we recommend you to use Menu props when available".
  4. Spy on console.warn in Legends.test.tsx with the gist above and open the menu: one matching warning is recorded per open.
  5. Move checkedValues from MenuList to Menu: the menu still renders 11 rows with identical aria state and selection, and no warning is recorded.

The same behavior is observable in a production bundle, so it is not a development-only StrictMode artifact.

Are you reporting an Accessibility issue?

no

Suggested severity

Low - Has or doesn't need a workaround

Products/sites affected

Internal Power Apps code app using @fluentui/react-charts Legends on dashboard views

Are you willing to submit a PR to fix?

yes

Validations

  • [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • [x] The provided reproduction is a minimal reproducible example of the bug.

jakesalvesen avatar Oct 20 '26 04:10 jakesalvesen

Fix PR: #36944. It moves checkedValues from MenuList to Menu in OverflowMenu and adds the regression test to the existing Legends - dynamic overflow harness.

jakesalvesen avatar Oct 20 '26 04:10 jakesalvesen