From dacb6d2082c9c958cd8c74c02a8cddfba03fbd00 Mon Sep 17 00:00:00 2001 From: "Eyo O. Eyo" <7893459+eokoneyo@users.noreply.github.com> Date: Tue, 11 Jun 2024 20:19:56 +0200 Subject: [PATCH] Explicitly support EUI Icons in EuiContextMenuItemIcon type definition (#7804) Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> --- packages/eui/changelogs/upcoming/7804.md | 1 + .../eui/src/components/context_menu/context_menu_item.tsx | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 packages/eui/changelogs/upcoming/7804.md diff --git a/packages/eui/changelogs/upcoming/7804.md b/packages/eui/changelogs/upcoming/7804.md new file mode 100644 index 00000000000..aa1f264cb5c --- /dev/null +++ b/packages/eui/changelogs/upcoming/7804.md @@ -0,0 +1 @@ +- Updated `EuiContextMenuItemIcon`'s type definition to explicitly define support for `EuiIcon`'s `IconType` \ No newline at end of file diff --git a/packages/eui/src/components/context_menu/context_menu_item.tsx b/packages/eui/src/components/context_menu/context_menu_item.tsx index e2088d0311c..82b4777ddc7 100644 --- a/packages/eui/src/components/context_menu/context_menu_item.tsx +++ b/packages/eui/src/components/context_menu/context_menu_item.tsx @@ -25,12 +25,12 @@ import { } from '../../services'; import { validateHref } from '../../services/security/href_validator'; import { CommonProps, keysOf } from '../common'; -import { EuiIcon } from '../icon'; +import { EuiIcon, type IconType } from '../icon'; import { EuiToolTip, EuiToolTipProps } from '../tool_tip'; import { euiContextMenuItemStyles } from './context_menu_item.styles'; -export type EuiContextMenuItemIcon = ReactElement | string | HTMLElement; +export type EuiContextMenuItemIcon = IconType | ReactElement | HTMLElement; export type EuiContextMenuItemLayoutAlignment = 'center' | 'top' | 'bottom'; @@ -124,7 +124,7 @@ export const EuiContextMenuItem: FunctionComponent = ({ /> ) : ( // Assume it's already an instance of an icon. - cloneElementWithCss(icon as ReactElement, { + cloneElementWithCss(icon, { css: styles.euiContextMenu__icon, }) ));