Skip to content

Commit 0b78e64

Browse files
adamwoodnzcursoragentCopilot
authored
Charts: Fix Line Chart Annotations Custom story error in Storybook (#47990)
* Charts: Replace gridicons with inline SVG to fix Storybook Vite transform error The gridicons package is CJS-only, which causes Vite's CJS-to-ESM interop in Storybook to fail when resolving the default export. This results in Gridicon being treated as an object instead of a React component, throwing 'Element type is invalid... got: object' in LineChartAnnotationLabelWithPopover. Replace the single Gridicon usage (cross icon in popover close button) with an inline SVG component using the same path data. This eliminates the CJS interop issue and also removes the gridicons dependency (~106KB) from the charts package. Ref CHARTS-208 * Add changelog entry for CHARTS-208 fix * Charts: Use @wordpress/icons instead of inline SVG for close icon Replace the inline CloseIcon SVG with the close icon from @wordpress/icons to align with WordPress ecosystem conventions. The package is tree-shakeable and already used widely across the monorepo. * Update changelog entry to reflect @wordpress/icons usage * Update changelog Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 902fa8d commit 0b78e64

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
Fix Line Chart Annotations Custom and Alert story errors in Storybook by replacing the CJS-only gridicons dependency with @wordpress/icons.

projects/js-packages/charts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@
8787
"@visx/vendor": "^3.12.0",
8888
"@visx/xychart": "^3.12.0",
8989
"@wordpress/i18n": "^6.0.0",
90+
"@wordpress/icons": "^12.0.0",
9091
"@wordpress/theme": "0.10.0",
9192
"@wordpress/ui": "0.9.0",
9293
"clsx": "2.1.1",
9394
"date-fns": "^4.1.0",
9495
"deepmerge": "4.3.1",
9596
"dompurify": "^3.3.3",
9697
"fast-deep-equal": "3.1.3",
97-
"gridicons": "3.4.2",
9898
"react-google-charts": "^5.2.1",
9999
"tslib": "2.8.1"
100100
},

projects/js-packages/charts/src/charts/line-chart/private/line-chart-annotation-label-popover.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { __ } from '@wordpress/i18n';
2+
import { Icon, close } from '@wordpress/icons';
23
import clsx from 'clsx';
3-
import Gridicon from 'gridicons';
44
import { useEffect, useId, useRef, useState } from 'react';
55
import { isSafari } from '../../../utils';
66
import styles from '../line-chart.module.scss';
@@ -100,7 +100,7 @@ const LineChartAnnotationLabelWithPopover: FC< LineChartAnnotationLabelWithPopov
100100
className={ styles[ 'line-chart__annotation-label-popover-close-button' ] }
101101
aria-label={ __( 'Close', 'jetpack-charts' ) }
102102
>
103-
<Gridicon icon="cross" size={ 16 } />
103+
<Icon icon={ close } size={ 16 } />
104104
</button>
105105
</div>
106106
</div>

0 commit comments

Comments
 (0)