-
-
Notifications
You must be signed in to change notification settings - Fork 50.3k
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组件,onChange中setValue为undefiend后,展示的label与实际的值不一致 #49157
Closed
JackWang032 opened this issue
May 31, 2024
· 5 comments
· May be fixed by react-component/select#1049
Closed
受控的Select组件,onChange中setValue为undefiend后,展示的label与实际的值不一致 #49157
JackWang032 opened this issue
May 31, 2024
· 5 comments
· May be fixed by react-component/select#1049
Labels
Comments
Start a new pull request in StackBlitz Codeflow. |
value={value || null}这样应该能先解决;估计是value为undefined的时候被识别成了非受控模式,change的时候触发了内部改变逻辑 |
QDyanbing
pushed a commit
to QDyanbing/select
that referenced
this issue
May 31, 2024
用 null 代替 undefined |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reproduction link
Steps to reproduce
受控下拉框无初始值, 当我选择某个选项后,在onChange中会判断是否要数据变更,如果不进行数据变更,则保持value不变(不进行setValue或者setValue为undefiend),这时展示的label还为所选的label而非空
What is expected?
与value保持一致
What is actually happening?
会将所选的label展示出来,但实际值还是空的, 尝试重新渲染后还是一样,如果setValue为null则不会出现该情况
实际业务场景为:一个表格列表中,有很多下拉框,选完后如果列表已存在该值,则保持原来的值并进行提示,如果这个下拉框一开始就是空值,那么就会遇到上述情况
The text was updated successfully, but these errors were encountered: