Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly support EUI Icons in EuiContextMenuItemIcon type definition #7804

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/eui/changelogs/upcoming/7804.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Modify `EuiContextMenuItemIcon` type definition to explicitly define support for EuiIcon's icon definition (i.e `IconType`)
cee-chen marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> | string | HTMLElement;
export type EuiContextMenuItemIcon = IconType | ReactElement<any>;
Copy link
Contributor

@cee-chen cee-chen May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes | HTMLElement as a supported type - was that intentional? It's not clear to me whether this change was meant to be additive or subtractive. If only the former, this unfortunately may end up messing with Kibana usages that pass, e.g. icon={someRawSvg} or similar.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @eokoneyo! Just checking in on this PR again - did you have a chance to look at the above? If not, I might go ahead and tweak your PR to add in | HTMLElement in again for safety and merge that if no type errors occur.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @eokoneyo! Just checking in on this PR again - did you have a chance to look at the above? If not, I might go ahead and tweak your PR to add in | HTMLElement in again for safety and merge that if no type errors occur.

Hey @cee-chen thanks for the ping, it wasn't particularly intentional. I'd made the assumption that even SVG usages would ideally be of the react component form. I'll be reverting to include support for HTMLElement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's definitely the ideal, but since it was previously supported we have to mark it a breaking change if we're no longer typing for it, which I'd prefer to avoid for small changes. There probably is some consumer out there who's passing a raw <svg /> element to this prop who would be upset otherwise 🫠


export type EuiContextMenuItemLayoutAlignment = 'center' | 'top' | 'bottom';

Expand Down Expand Up @@ -124,7 +124,7 @@ export const EuiContextMenuItem: FunctionComponent<Props> = ({
/>
) : (
// Assume it's already an instance of an icon.
cloneElementWithCss(icon as ReactElement, {
cloneElementWithCss(icon, {
css: styles.euiContextMenu__icon,
})
));
Expand Down
Loading