Skip to content

Commit

Permalink
fix: 修改form下的picker在第一次不选择选项,直接取消选择后再次点击picker,出现第一项被选中的问题 --issue#2290
Browse files Browse the repository at this point in the history
  • Loading branch information
songjiaming committed Jun 18, 2024
1 parent 6aba177 commit 76a5e85
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/packages/picker/picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ const InternalPicker: ForwardRefRenderFunction<
}

useEffect(() => {
setInnerValue(innerValue !== selectedValue ? selectedValue : innerValue)
// 此hook的作用是‘如果内部选中值与用户选中值不同则把内部值置用户选中值’保证用户打开选项时选中的是选择的值。
// 但是当用户并没有进行确认选择,则不需要进行修改innerValue,否则会出现 issue#2290的问题
if (innerValue !== selectedValue && selectedValue.length > 0) {
setInnerValue(selectedValue)
}
}, [innerVisible, selectedValue])

useEffect(() => {
Expand Down

0 comments on commit 76a5e85

Please sign in to comment.