-
-
Notifications
You must be signed in to change notification settings - Fork 928
Sender 组件插槽模式tag标签添加可关闭功能 #1410
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,6 +140,7 @@ const SlotTextArea = React.forwardRef<SlotTextAreaRef>((_, ref) => { | |
| const renderSlot = (node: SlotConfigType, slotSpan: HTMLSpanElement) => { | ||
| if (!node.key) return null; | ||
| const value = getSlotValues()[node.key]; | ||
| console.log(node, 'nodeqqqqq'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 请移除调试用的
🤖 Prompt for AI Agents |
||
| const renderContent = () => { | ||
| switch (node.type) { | ||
| case 'input': | ||
|
|
@@ -195,7 +196,31 @@ const SlotTextArea = React.forwardRef<SlotTextAreaRef>((_, ref) => { | |
| </Dropdown> | ||
| ); | ||
| case 'tag': | ||
| return <div className={`${prefixCls}-slot-tag`}>{node.props?.label || ''}</div>; | ||
| return ( | ||
| <div className={`${prefixCls}-slot-tag`}> | ||
| {node.props?.label || ''} | ||
| {node.allowClose && ( | ||
| <span | ||
| className={`${prefixCls}-slot-tag-close`} | ||
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
| // 从配置中移除 | ||
| slotConfigRef.current = slotConfigRef.current.filter( | ||
| (item) => item.key !== node.key, | ||
| ); | ||
| // 从DOM中移除 | ||
| const slotDom = getSlotDom(node.key as string); | ||
| slotDom?.parentNode?.removeChild(slotDom); | ||
| // 更新状态 | ||
| const newValue = getEditorValue(); | ||
| onChange?.(newValue.value, undefined, newValue.config); | ||
| }} | ||
|
Comment on lines
+205
to
+217
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个
建议重构此逻辑,避免在事件处理器中直接操作DOM和ref。一个更安全的方式是,在临时修改DOM以计算新值后,立即恢复DOM,然后通过 |
||
| > | ||
| × | ||
| </span> | ||
| )} | ||
| </div> | ||
| ); | ||
| case 'custom': | ||
| return node.customRender?.( | ||
| value, | ||
|
|
||
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.
这里有一个
console.log语句,可能是用于调试的。在合并到主分支之前,建议将其移除,以保持代码库的整洁。