Skip to content

Commit

Permalink
fix: #1842
Browse files Browse the repository at this point in the history
  • Loading branch information
Wugaoliang committed Aug 6, 2021
1 parent d1601d9 commit 827deda
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# 3.7.1

- 新增 `Modal` confirmLoading 控制确定按钮的 loading 状态[#1866](https://github.com/XiaoMi/hiui/issues/1866)

- 新增 `Cascader` onOpen 下拉菜单打开、onClose 下拉菜单关闭回调方法,优化动态加载数据功能 [#1854](https://github.com/XiaoMi/hiui/issues/1854)
- 新增 `Table` 组件 align 属性接受 center 属性 [#1835](https://github.com/XiaoMi/hiui/issues/1835)
- 新增 `Table` 组件 拖拽功能 [#1851](https://github.com/XiaoMi/hiui/issues/1851)
- 新增 `Select` 组件 renderExtraFooter 自定义下拉菜单底部渲染函数[#1864](https://github.com/XiaoMi/hiui/issues/1864)
- 优化 `DatePicker` 组件在 `Table` 组件中受控形态下无法选中问题 [#1844](https://github.com/XiaoMi/hiui/issues/1844)
- 优化 `Carousel` 内容宽度根据容器改变自适应 [#1834](https://github.com/XiaoMi/hiui/issues/1834)
- 修复 `Form` 组件对 Counter 组件默认值为 0 校验异常问题 [#1842](https://github.com/XiaoMi/hiui/issues/1842)
- 修复 `Preview` 组件,图片打开失败时,页面一直处在加载状态 [#1816](https://github.com/XiaoMi/hiui/issues/1816)
- 修复 `HiRequest` 在 type='download'时 不能正确解析 filename 问题 [#1820](https://github.com/XiaoMi/hiui/issues/1820)
- 优化 `Carousel` 内容宽度根据容器改变自适应 [#1834](https://github.com/XiaoMi/hiui/issues/1834)
Expand Down
10 changes: 8 additions & 2 deletions components/form/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const FormItem = (props) => {
const getItemfield = useCallback(() => {
let _propsField = propsField
if (_type === 'list' && name) {
_propsField = _propsField + '&&' + name
_propsField = _propsField + '#' + name
}
return Array.isArray(propsField) ? propsField[propsField.length - 1] : _propsField
}, [propsField, name])
Expand Down Expand Up @@ -272,8 +272,9 @@ const FormItem = (props) => {
? e.target[valuePropName]
: e
if (displayName === 'Counter') {
value = args[0]
value = args[0] || 0
}
console.log('value', displayName, value)
eventInfo.current = { eventName, e, args, componentProps, value }
handleField(eventName, value)
setValue(value)
Expand All @@ -296,6 +297,10 @@ const FormItem = (props) => {
const isExist = _fields.some((item) => {
return item.field === _field
})
const displayName = !!children && children.type && children.type.displayName
if (displayName === 'Counter' && _value === undefined) {
_value = 0
}
if (_field && !isExist) {
_value = initialValues && typeof initialValues[field] !== 'undefined' ? initialValues[_field] : _value
if (_type === 'list' && listItemValue) {
Expand Down Expand Up @@ -340,6 +345,7 @@ const FormItem = (props) => {
return null
}
const propChild = children ? children.props : {}

return Array.isArray(children) || !React.isValidElement(children)
? children
: React.cloneElement(children, {
Expand Down
2 changes: 1 addition & 1 deletion components/form/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'lodash'

// 需要做一个filed的规则解析
const tranformListValues = (field, listNestValues, value, listname) => {
const fieldSplit = field.split('&&')
const fieldSplit = field.split('#')
const key = fieldSplit[1]
const keyName = fieldSplit[0]
if (listNestValues[listname][keyName]) {
Expand Down

0 comments on commit 827deda

Please sign in to comment.