fix(select): 修复Select 通过 showClear 清空后,用户配置的 blur 失焦触发校验的Props 不生效的bug #1865
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.
中文模板 / Chinese Template
What kind of change does this PR introduce? (check at least one)
PR description
Fixes #1453
Changelog
🇨🇳 Chinese
修复原因:
因为Select在Open的时候,会注册registerClickOutsideHandler事件,来触发blur的规则校验,但是配置showClear之后,点击clear按钮,并没有open select,所以没有注册registerClickOutsideHandler,所以在clearSelected的时候注册registerClickOutsideHandler事件,这里不怕多次点击clear按钮会重复注册,因为注册事件的时候里面判断会解绑多余的注册事件,如下源码:
tooltip/index.ts
🇺🇸 English
Reason for repair:
Because when Select is Open, it will register the registerClickOutsideHandler event to trigger blur rule verification. However, after configuring showClear, clicking the clear button does not open select, so the registerClickOutsideHandler is not registered, so the registerClickOutsideHandler event is registered when clearSelected. Don't be afraid here. Clicking the clear button multiple times will result in repeated registration, because when registering events, it will be judged to unbind redundant registration events, as shown in the following source code:
tooltip/index.ts
Checklist
Other
Additional information