Fix legends selection bugs#24563
Conversation
📊 Bundle size report🤖 This report was generated against 4d58b78e55691de6f14746dbd282c315771be933 |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 1b75d31:
|
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: 4d58b78e55691de6f14746dbd282c315771be933 (build) |
7016020 to
b56a750
Compare
| }); | ||
| } | ||
|
|
||
| private _onLegendLeave(isLegendFocused?: boolean): void { |
There was a problem hiding this comment.
Do you need to keep track of isLegendFocused flag.
There was a problem hiding this comment.
No, it is not needed in the new logic
| this.setState({ isCircleClicked: true }); | ||
| }; | ||
|
|
||
| private _getOpacity = (selectedArea: string): number => { |
There was a problem hiding this comment.
Is _getOpacity applicable for legends
There was a problem hiding this comment.
No, it is only applicable for elements inside the chart
| }, | ||
| ); | ||
| this.setState({ isHoverCardVisible: false }); | ||
| const activeOverflowItem = find(legends, (legend: ILegend) => legend.title === this.state.activeLegend); |
There was a problem hiding this comment.
Is canSelectMultipleLegends not needed in the new logic
| ) { | ||
| legendColor = color; | ||
| const inSelectedState = this.state.selectedLegend !== '' || this.state.selectedLegends.length > 0; | ||
| if (inSelectedState) { |
There was a problem hiding this comment.
Could you share what all you have tested
There was a problem hiding this comment.
The color of the legend is decided based on these 3 cases:
- When 1 or more legends are selected: The selected legends have their respective colors but the unselected legends have white color
- When no legend is selected but there is a hovered legend (the legend which has the mouse pointer over it): All legends except the hovered legend have white color
- When no legend is selected or hovered (default case): All legends have their respective colors
Perf Analysis (
|
| Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
|---|---|---|---|---|---|
| Avatar | mount | 1251 | 1311 | 5000 | |
| Button | mount | 866 | 925 | 5000 | |
| FluentProvider | mount | 1471 | 1500 | 5000 | |
| FluentProviderWithTheme | mount | 625 | 568 | 10 | |
| FluentProviderWithTheme | virtual-rerender | 592 | 561 | 10 | |
| FluentProviderWithTheme | virtual-rerender-with-unmount | 550 | 630 | 10 | |
| MakeStyles | mount | 1793 | 1923 | 50000 | |
| SpinButton | mount | 2524 | 2515 | 5000 |
ab33291 to
376a49e
Compare
| shouldHighlight = this.state.titleForHoverCard === legendTitle; | ||
| } | ||
| return shouldHighlight ? '' : '0.1'; | ||
| const opacity = this._legendHighlighted(legendTitle) || this._noLegendHighlighted() ? '' : '0.1'; |
There was a problem hiding this comment.
Can you confirm that this value is '' and not something else.
There was a problem hiding this comment.
The browser treats empty opacity as 100%. Instead of an empty string, '1' would be more intuitive.
| if (this.state.isLegendHovered || this.state.isLegendSelected) { | ||
| shouldHighlight = this.state.selectedLegendTitle === point.legend; | ||
| } | ||
| const shouldHighlight = this._legendHighlighted(point.legend!) || this._noLegendHighlighted() ? true : false; |
There was a problem hiding this comment.
Add brackets to clarify the scope of expression
There was a problem hiding this comment.
I tried to add the brackets but they get removed automatically on formatting
* fix legends selection reset bug * sync LineChart legend states * sync AreaChart legend states * sync HeatMapChart legend states * sync StackedBarChart legend states * sync VerticalBarChart legend states * sync DonutChart legend states * sync GroupedVerticalBarChart legend states * sync VerticalStackedBarChart legend states * refactor * add change file * rename function * minor * add comments
* fix legends selection reset bug * sync LineChart legend states * sync AreaChart legend states * sync HeatMapChart legend states * sync StackedBarChart legend states * sync VerticalBarChart legend states * sync DonutChart legend states * sync GroupedVerticalBarChart legend states * sync VerticalStackedBarChart legend states * refactor * add change file * rename function * minor * add comments

Current Behavior
New Behavior