Skip to content

fix(react-charts): handle stale legend overflow counts - #36691

Open
Jake Salvesen (jakesalvesen) wants to merge 1 commit into
microsoft:masterfrom
jakesalvesen:fix/36641-legends-overflow-shrink
Open

fix(react-charts): handle stale legend overflow counts#36691
Jake Salvesen (jakesalvesen) wants to merge 1 commit into
microsoft:masterfrom
jakesalvesen:fix/36641-legends-overflow-shrink

Conversation

@jakesalvesen

Copy link
Copy Markdown

Previous Behavior

Legends could crash while reconciling a dynamic item-count change. When an overflowed list shrank, useOverflowMenu() could briefly return the previous overflowCount; if that count exceeded the current itemIds.length, remainingItemsCount became negative and OverflowMenu dereferenced items[i].props for a missing item.

This produced TypeError: Cannot read properties of undefined (reading 'props') and could unmount the containing chart through its React error boundary.

New Behavior

  • Suppresses the overflow menu while its snapshot reports more overflowed items than currently exist.
  • Defensively skips a missing overflow item if the arrays are temporarily out of sync.
  • Adds a regression test that establishes 14 overflowed legends, shrinks the list from 17 items to 3, and verifies the stale menu is removed while all remaining options stay visible.
  • Adds the required patch change file for @fluentui/react-charts.

Validation

  • Focused Legends.test.tsx: 13 passed, 4 skipped, 5 snapshots passed.
  • react-charts:lint: 0 errors (438 existing package warnings).
  • Full react-charts:test: 907 passed, 86 skipped; six unrelated HeatMapChart date snapshots fail locally on Windows because expected Mar/01 / Mar/02 render as Feb/29 / Mar/01.
  • Package type-check was attempted, but the local Windows clone could not resolve built workspace package declarations after dependency builds failed on a path-rewrite issue. Upstream CI remains authoritative for that gate.

Related Issue(s)

@jakesalvesen

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@jakesalvesen
Jake Salvesen (jakesalvesen) marked this pull request as ready for review September 3, 2026 23:46
@jakesalvesen

Copy link
Copy Markdown
Author

@microsoft/charting-team this is ready for review. The focused Legends regression and package lint pass locally; the PR includes the required @fluentui/react-charts patch change file.

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.

[Bug]: Legends OverflowMenu crashes after the legend count changes (items[i] is undefined)

1 participant