-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
fix: createIcon props #2629
fix: createIcon props #2629
Conversation
48c7232
to
5b5018f
Compare
@@ -143,7 +143,7 @@ function createAction(content: ReactNode | ComponentType<any> | IPublicTypeActio | |||
}); | |||
}} | |||
> | |||
{icon && createIcon(icon)} | |||
{icon && createIcon(icon, { key, node })} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的 node 得用 node.internalToShellNode()
另外,还需要补充一下相关的示例
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
示例:
// demo.tsx
import React from 'react';
import { Node } from '@alilc/lowcode-designer';
import { Dropdown, Icon } from '@alifd/next';
import store from 'store';
const model = [
{
value: 'option1',
label: '选项1',
},
{
value: ' option2',
label: '选项2',
},
]
import './index.less';
function SettetSwitch(props: any) {
// 该 node 为 createIcon 传入
const { node } = props;
return (
<Dropdown
trigger={<Icon type="switch" size="small" />}
onVisibleChange={() => store.set('setterValue', null)}
triggerType={['hover']}
>
<div>
{model.map((item) => (
<div
className="component-select-item"
onClick={() => {
// 设置物料属性
node?.setPropValue('setter.componentName', item.value);
node?.document?.selection.remove(node.id);
}}
>
{item.label}
</div>
))}
</div>
</Dropdown>
);
}
export default {
name: 'settetSwitch',
content: {
icon: <SettetSwitch />,
title: 'Setter切换',
},
condition: (node: Node) => {
return node.componentMeta?.componentName === 'Setters';
},
important: true,
};
// plugin.tsx
export default async function registerPlugins() {
// 在设计器辅助层增加一个扩展 action
material.addBuiltinComponentAction(setterSelect);
}
@Super-Rz 分支指向 develop。 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2629 +/- ##
=======================================
Coverage 85.04% 85.04%
=======================================
Files 222 222
Lines 8967 8967
Branches 2111 2111
=======================================
Hits 7626 7626
Misses 1248 1248
Partials 93 93 ☔ View full report in Codecov by Sentry. |
* fix: createIcon props * fix: createIcon props
addBuiltinComponentAction中icon的dom无法获取node节点,建议在 createAction中的 createIcon 补充 key,node参数
issuesId:#2622