diff --git a/packages/amis-ui/src/components/icons.tsx b/packages/amis-ui/src/components/icons.tsx index 3ee2fd4b8..0ba41e5e7 100644 --- a/packages/amis-ui/src/components/icons.tsx +++ b/packages/amis-ui/src/components/icons.tsx @@ -273,7 +273,15 @@ export function Icon({ // 直接的icon dom if (React.isValidElement(icon)) { - return icon; + return React.cloneElement(icon, { + ...((icon.props as any) || {}), + className: cxClass( + cx(className, classNameProp), + (icon.props as any).className + ), + style, + onClick + }); } // 从css变量中获取icon diff --git a/packages/amis/__tests__/renderers/Form/__snapshots__/combo.test.tsx.snap b/packages/amis/__tests__/renderers/Form/__snapshots__/combo.test.tsx.snap index c3664310d..674d5ad0e 100644 --- a/packages/amis/__tests__/renderers/Form/__snapshots__/combo.test.tsx.snap +++ b/packages/amis/__tests__/renderers/Form/__snapshots__/combo.test.tsx.snap @@ -1072,7 +1072,7 @@ exports[`Renderer:combo with conditions: add button open 1`] = ` class="cxd-Button cxd-Button--info cxd-Button--size-sm" > 新增 diff --git a/packages/amis/src/renderers/Collapse.tsx b/packages/amis/src/renderers/Collapse.tsx index 821717dc5..004cb5bcf 100644 --- a/packages/amis/src/renderers/Collapse.tsx +++ b/packages/amis/src/renderers/Collapse.tsx @@ -190,7 +190,11 @@ export default class Collapse extends React.Component { expandIcon={ expandIcon ? ( typeof (expandIcon as any).icon === 'object' ? ( - + ) : ( render('arrow-icon', expandIcon || '', { className: cx('Collapse-icon-tranform') diff --git a/packages/amis/src/renderers/Icon.tsx b/packages/amis/src/renderers/Icon.tsx index 615ed9acb..2ae83a183 100644 --- a/packages/amis/src/renderers/Icon.tsx +++ b/packages/amis/src/renderers/Icon.tsx @@ -73,8 +73,11 @@ export class Icon extends React.Component { css, env } = this.props; + let icon = this.props.icon; - const icon = filter(this.props.icon, data); + if (typeof icon === 'string') { + icon = filter(this.props.icon, data); + } return ( <>