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
feat: support mentions onece delete #48389
base: feature
Are you sure you want to change the base?
Conversation
Run & review this pull request in StackBlitz Codeflow. |
👁 Visual Regression Report for PR #48389 Failed ❌
Check Full Report for details |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature #48389 +/- ##
===========================================
- Coverage 100.00% 99.93% -0.07%
===========================================
Files 744 744
Lines 12887 12925 +38
Branches 3381 3395 +14
===========================================
+ Hits 12887 12916 +29
- Misses 0 9 +9 ☔ View full report in Codecov by Sentry. |
新增一个demo吧? |
{...restProps} | ||
filterOption={mentionsfilterOption} | ||
onKeyDown={onKeyDown} |
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.
事件丢了,应该还需要透一下 props. onKeyDown?.(event)
@@ -45,6 +46,7 @@ export interface MentionProps extends Omit<RcMentionsProps, 'suffix'> { | |||
status?: InputStatus; | |||
options?: MentionsOptionProps[]; | |||
popupClassName?: string; | |||
itemOnceDelete?: boolean; |
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.
这个 prop 不符合 antd 的 naming standard,可以先看看现有的 API 命名有没有可以复用的
components/mentions/index.tsx
Outdated
status: customStatus, | ||
allowClear = false, | ||
popupClassName, | ||
style, | ||
variant: customVariant, | ||
...restProps | ||
} = props; | ||
const [data, setData] = React.useState<string>(props.value ?? props.defaultValue ?? ''); |
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.
useState
参数只有初始化会生效,不会同步 value
,这么写不受控
components/mentions/index.tsx
Outdated
const onKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => { | ||
if (e.keyCode === KeyCode.BACKSPACE && itemOnceDelete) { | ||
if (data) { | ||
setData(data.split('@').slice(0, -1).join('@')); |
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.
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.
working on it
还有一个问题:输入@然后输入不是options里面的值, |
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
#47968
💡 Background and solution
📝 Changelog
☑️ Self-Check before Merge