-
-
Notifications
You must be signed in to change notification settings - Fork 466
fix:Select with maxCount limit does not allow removal of selected opt… #1148
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
Open
765477020
wants to merge
2
commits into
react-component:master
Choose a base branch
from
765477020:fix/maxCountBug
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Walkthrough
此次更改调整了 OptionList 组件中 ENTER 键的键盘事件处理逻辑。现在会优先判断当前激活项是否缺失或被禁用,若是,则直接调用 onSelectValue(undefined) 并返回;否则根据 maxCount 和当前值集合判断是否允许选择或取消选择。
## Changes
| 文件或文件组 | 变更摘要 |
|------------------------------|--------------------------------------------------------|
| src/OptionList.tsx | 优化了 ENTER 键的选择逻辑,明确处理激活项缺失、禁用和最大数量限制的情况。 |
| tests/OptionList.test.tsx | 新增测试用例,验证多选且达到最大选择数时按 ENTER 键的行为,确保触发正确的取消选择回调。 |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant User as 用户
participant OptionList as OptionList组件
participant onSelectValue as onSelectValue回调
User->>OptionList: 按下 ENTER 键
OptionList->>OptionList: 检查激活项是否缺失或禁用
alt 缺失或禁用
OptionList->>onSelectValue: onSelectValue(undefined)
OptionList-->>User: 结束
else 存在且可用
OptionList->>OptionList: 检查maxCount和rawValues
alt 可选择或已选中
OptionList->>onSelectValue: onSelectValue(激活项值)
else 不可选择
OptionList->>onSelectValue: onSelectValue(undefined)
end
end Possibly related PRs
Suggested reviewers
Poem
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
需要补一个测试用例。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
解决这个问题,ant-design/ant-design#53637
Summary by CodeRabbit