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
select onSearch第一次促发查询出列表数据后,选中一个option,然后重新输入查询,这次没有查出数据, 此时失去焦点期望select为空,但实际上却是第一次选中的值 #16310
Comments
Hello @hualinIT. Please provide a online reproduction by forking this link https://u.ant.design/codesandbox-repro or a minimal GitHub repository. Issues labeled by 你好 @hualinIT, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。7 天内未跟进的 issue 将会被自动关闭。 |
我的也是这个情况 |
repo: https://codesandbox.io/embed/xvox9o3zlz |
value 是受控属性。如果设置了 value,无论是否 Option 里是否有这个值都会展示它。它就是 Select 的值。 |
@zombieJ 要怎么处理它使它失去焦点为空呢,而不是恢复成以前的选中的值 https://codesandbox.io/embed/xvox9o3zlz |
function handleSearch(val) {
if (val === "a") {
setTimeout(() => {
setOptions([{ label: "a", value: "a" }]);
}, 1000);
} else {
setOptions([]);
+ setValue(undefined);
}
} |
Reproduction link
https://codesandbox.io/embed/n94yx206rl
Steps to reproduce
What is expected?
期望 步骤3的值为空
What is actually happening?
实际结果恢复成步骤1选中的值了
The text was updated successfully, but these errors were encountered: