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

feat: support mentions onece delete #48389

Open
wants to merge 7 commits into
base: feature
Choose a base branch
from

Conversation

CooperHash
Copy link
Contributor

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Workflow
  • Other (about what?)

🔗 Related issue link

#47968

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English add a new props to delete item in Mention
🇨🇳 Chinese 新增Mention组件的props

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

Copy link

stackblitz bot commented Apr 11, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Contributor

github-actions bot commented Apr 11, 2024

👁 Visual Regression Report for PR #48389 Failed ❌

🎯 Target branch: feature (1092660)
📖 View Full Report ↗︎

Image name Expected Actual Diff
steps-label-placement.compact.css-var.png feature: 1092660e0ac8e46efcdcf4e240e40c07242c210e current: pr-48389 diff
steps-label-placement.dark.css-var.png feature: 1092660e0ac8e46efcdcf4e240e40c07242c210e current: pr-48389 diff
steps-label-placement.default.css-var.png feature: 1092660e0ac8e46efcdcf4e240e40c07242c210e current: pr-48389 diff
steps-progress-debug.dark.css-var.png feature: 1092660e0ac8e46efcdcf4e240e40c07242c210e current: pr-48389 diff
steps-progress.compact.css-var.png feature: 1092660e0ac8e46efcdcf4e240e40c07242c210e current: pr-48389 diff

Check Full Report for details

Copy link
Contributor

github-actions bot commented Apr 11, 2024

Preview is ready

Copy link

codesandbox-ci bot commented Apr 11, 2024

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.

Copy link

codecov bot commented Apr 11, 2024

Codecov Report

Attention: Patch coverage is 76.31579% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 99.93%. Comparing base (1092660) to head (733cc88).

Files Patch % Lines
components/mentions/index.tsx 76.31% 9 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@CooperHash
Copy link
Contributor Author

@yoyo837

@yoyo837 yoyo837 linked an issue Apr 11, 2024 that may be closed by this pull request
@yoyo837
Copy link
Contributor

yoyo837 commented Apr 11, 2024

新增一个demo吧?
文档中英文要一起修改

{...restProps}
filterOption={mentionsfilterOption}
onKeyDown={onKeyDown}
Copy link
Member

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;
Copy link
Member

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 命名有没有可以复用的

status: customStatus,
allowClear = false,
popupClassName,
style,
variant: customVariant,
...restProps
} = props;
const [data, setData] = React.useState<string>(props.value ?? props.defaultValue ?? '');
Copy link
Member

Choose a reason for hiding this comment

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

useState 参数只有初始化会生效,不会同步 value,这么写不受控

const onKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.keyCode === KeyCode.BACKSPACE && itemOnceDelete) {
if (data) {
setData(data.split('@').slice(0, -1).join('@'));
Copy link
Member

Choose a reason for hiding this comment

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

@ 可以自定义,不能写死 @。而且这个逻辑没考虑光标位置,行为是不正确的:

非 mention 对象不应该被删除

Kapture 2024-04-11 at 16 16 48

删除的 mention 对象不正确

Kapture 2024-04-11 at 16 20 00

Copy link
Contributor Author

Choose a reason for hiding this comment

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

working on it

@CooperHash
Copy link
Contributor Author

还有一个问题:输入@然后输入不是options里面的值,@options1 @xxxx (光标在最后)这样删除的逻辑是 => 变成@option1还是@options1 @xxx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1.mentions组件删除at的人可以整体删除而不是删除字
5 participants