diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9f0f5db93..88baf74da 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,15 @@
# 更新日志
+## 2.2.1
+
+- 修复 `` 多选时历史数据污染的问题 [#606](https://github.com/XiaoMi/hiui/issues/606)
+- 修复 `` data 无法更新的问题 [#603](https://github.com/XiaoMi/hiui/issues/603)
+- 修复 `` data 无法更新的问题 [#607](https://github.com/XiaoMi/hiui/issues/607)
+- 修复 `` 组件销毁没有清空定时器的问题 [#624](https://github.com/XiaoMi/hiui/issues/624)
+- 修复 `` onClose 失效的问题 [#627](https://github.com/XiaoMi/hiui/issues/627)
+- 修复 `` 长度不够展示时间被遮挡的问题 [#615](https://github.com/XiaoMi/hiui/issues/615)
+- 修复 `
` 动态渲染的时候 removeField 数量不正确的问题 [#636](https://github.com/XiaoMi/hiui/issues/636)
+
## 2.2.0
- 新增 `` 走马灯组件 [#115](https://github.com/XiaoMi/hiui/issues/115)
diff --git a/components/form/Form.js b/components/form/Form.js
index 579eaf521..1f7c906e7 100644
--- a/components/form/Form.js
+++ b/components/form/Form.js
@@ -41,13 +41,11 @@ class Form extends Component {
}
removeField (prop) {
- const fields = this.state.fields.filter(
- (field) => field.props.field !== prop
- )
-
- this.setState({
- fields
- })
+ this.setState((prevState) => ({
+ fields: prevState.fields.filter(
+ (field) => field.props.field !== prop
+ )
+ }))
}
validate (cb) {
diff --git a/components/index.js b/components/index.js
index 51ee73cd2..cf4121537 100755
--- a/components/index.js
+++ b/components/index.js
@@ -4,7 +4,7 @@ export { default as Pagination } from './pagination'
export { default as Tabs } from './tabs'
export { default as Table } from './table'
export { default as Notification } from './notification'
-export { handleNotificate } from './notification/HandleNotification'
+export { default as handleNotificate } from './notification/HandleNotification'
export { default as Modal } from './modal'
export { default as Alert } from './alert'
export { default as Panel } from './panel'
diff --git a/components/loading/index.js b/components/loading/index.js
index 1c5381033..56a890c4e 100755
--- a/components/loading/index.js
+++ b/components/loading/index.js
@@ -78,7 +78,7 @@ function deprecatedOpen ({ target, tip } = {}) {
}
function openWrapper (target, options) {
- if (target === null || (target && React.isValidElement(React.cloneElement(target)))) {
+ if (arguments.length >= 2) {
open(target, options)
} else {
return deprecatedOpen(target)
diff --git a/components/notice/Notice.js b/components/notice/Notice.js
index f01abcc0c..f25c1b4fa 100755
--- a/components/notice/Notice.js
+++ b/components/notice/Notice.js
@@ -5,17 +5,22 @@ import { CSSTransition } from 'react-transition-group'
export default class Notice extends Component {
state = { open: false }
+ openTimer = null
+ closeTimer = null
componentDidMount () {
this.setState({
open: true
})
if (this.props.duration !== null) {
- setTimeout(() => {
+ this.openTimer = setTimeout(() => {
this.setState({ open: false })
}, this.props.duration || 3000)
}
}
-
+ componentWillUnmount () {
+ clearTimeout(this.openTimer)
+ clearTimeout(this.closeTimer)
+ }
closeNotice = e => {
if (e) {
e.stopPropagation()
@@ -32,7 +37,7 @@ export default class Notice extends Component {
timeout={0}
classNames={`hi-${prefix}`}
onExited={() => {
- setTimeout(() => this.closeNotice(), 300)
+ this.closeTimer = setTimeout(() => this.closeNotice(), 300)
}}
>
diff --git a/components/notice/NoticeContainer.js b/components/notice/NoticeContainer.js
index 113d47c27..9ecfdf883 100755
--- a/components/notice/NoticeContainer.js
+++ b/components/notice/NoticeContainer.js
@@ -30,7 +30,10 @@ export default class NoticeContainer extends Component {
{
+ this.removeNotice(noticeId)
+ notice.onClose && notice.onClose()
+ }}
duration={notice.duration}
prefix={prefix}
type={notice.type}
diff --git a/components/notification/index.js b/components/notification/index.js
index 48862f5fb..c06a5b2fe 100755
--- a/components/notification/index.js
+++ b/components/notification/index.js
@@ -3,7 +3,7 @@ import './style/index'
import React from 'react'
import Button from '../button'
import classNames from 'classnames'
-import handleNotificate from './HandleNotification'
+import _handleNotificate from './HandleNotification'
const iconMap = {
success: 'chenggong',
@@ -12,6 +12,8 @@ const iconMap = {
info: 'tishi'
}
+export const handleNotificate = _handleNotificate
+
const notification = {
close: key => {
notice.close('notification', key)
diff --git a/components/select/Select.js b/components/select/Select.js
index dd147e10c..03f49f11d 100644
--- a/components/select/Select.js
+++ b/components/select/Select.js
@@ -119,19 +119,9 @@ class Select extends Component {
}
componentWillReceiveProps (nextProps) {
- if (!shallowEqual(nextProps.value, this.props.value)) {
- const selectedItems = this.resetSelectedItems(
- nextProps.value,
- this.state.dropdownItems
- ) // 异步获取时会从内部改变dropdownItems,所以不能从list取
-
- this.setState({
- selectedItems
- })
- }
if (!shallowEqual(nextProps.data, this.props.data)) {
const selectedItems = this.resetSelectedItems(
- nextProps.value,
+ nextProps.value || this.state.selectedItems,
nextProps.data,
true
)
@@ -139,6 +129,17 @@ class Select extends Component {
selectedItems,
dropdownItems: cloneDeep(nextProps.data)
})
+ } else {
+ if (!shallowEqual(nextProps.value, this.props.value)) {
+ const selectedItems = this.resetSelectedItems(
+ nextProps.value,
+ this.state.dropdownItems
+ ) // 异步获取时会从内部改变dropdownItems,所以不能从list取
+
+ this.setState({
+ selectedItems
+ })
+ }
}
}
@@ -166,24 +167,14 @@ class Select extends Component {
return dataSource && !!dataSource.url
}
- resetSelectedItems (value, dropdownItems, listChanged = false) {
+ resetSelectedItems (value, dropdownItems = [], listChanged = false) {
const values = this.parseValue(value)
- const selectedItems =
- listChanged && this.props.type === 'multiple'
- ? this.state.selectedItems
- : [] // 如果是多选,dropdownItems有改动,需要保留之前的选中值
-
- dropdownItems &&
- dropdownItems.map((item) => {
- if (values.indexOf(item.id) !== -1) {
- const itemIndex = selectedItems.findIndex((sItem) => {
- // 多选时检查是否已选中
- return sItem.id === item.id
- })
-
- itemIndex === -1 && selectedItems.push(item)
- }
- })
+ let selectedItems = []
+ dropdownItems.forEach(item => {
+ if (values.includes(item.id)) {
+ selectedItems.push(item)
+ }
+ })
return selectedItems
}
diff --git a/components/tooltip/index.js b/components/tooltip/index.js
index 035145ff8..f8603ce7b 100644
--- a/components/tooltip/index.js
+++ b/components/tooltip/index.js
@@ -27,7 +27,7 @@ class Tooltip extends Component {
}
// 兼容处理 button disabled tooltip 不消失的问题
compatDisabledBtn = el => {
- if (el.type.IS_HI_COMPONENT && el.props.disabled) {
+ if (el && el.type && el.type.IS_HI_COMPONENT && el.props.disabled) {
return React.cloneElement(el, {
style: {
...el.props.style,
diff --git a/docs/demo/modal/section-size.jsx b/docs/demo/modal/section-size.jsx
index d3e94f474..4bf25609c 100644
--- a/docs/demo/modal/section-size.jsx
+++ b/docs/demo/modal/section-size.jsx
@@ -3,7 +3,7 @@ import DocViewer from '../../../libs/doc-viewer'
import Button from '../../../components/button'
import Modal from '../../../components/modal'
import Radio from '../../../components/radio'
-const desc = '通过 size 自定义尺寸,可使用 large、normal、small,默认为 default'
+const desc = '通过 size 自定义尺寸,可使用 large、default、small,默认为 default'
const prefix = 'modal-size'
const code = `import React from 'react'
import Button from '@hi-ui/hiui/es/button'
diff --git a/docs/zh-CN/components/changelog.mdx b/docs/zh-CN/components/changelog.mdx
index 91b88af8e..ec5806ceb 100644
--- a/docs/zh-CN/components/changelog.mdx
+++ b/docs/zh-CN/components/changelog.mdx
@@ -1,5 +1,15 @@
# 更新日志
+## 2.2.1
+
+- 修复 `` 多选时历史数据污染的问题 [#606](https://github.com/XiaoMi/hiui/issues/606)
+- 修复 `` data 无法更新的问题 [#603](https://github.com/XiaoMi/hiui/issues/603)
+- 修复 `` data 无法更新的问题 [#607](https://github.com/XiaoMi/hiui/issues/607)
+- 修复 `` 组件销毁没有清空定时器的问题 [#624](https://github.com/XiaoMi/hiui/issues/624)
+- 修复 `` onClose 失效的问题 [#627](https://github.com/XiaoMi/hiui/issues/627)
+- 修复 `` 长度不够展示时间被遮挡的问题 [#615](https://github.com/XiaoMi/hiui/issues/615)
+- 修复 `` 动态渲染的时候 removeField 数量不正确的问题 [#636](https://github.com/XiaoMi/hiui/issues/636)
+
## 2.2.0
- 新增 `` 走马灯组件 [#115](https://github.com/XiaoMi/hiui/issues/115)
diff --git a/docs/zh-CN/components/dropdown.mdx b/docs/zh-CN/components/dropdown.mdx
index 314674e06..3b4761417 100755
--- a/docs/zh-CN/components/dropdown.mdx
+++ b/docs/zh-CN/components/dropdown.mdx
@@ -44,7 +44,7 @@ import { Badge } from '@libs'
| onClick | 点击后的回调 | (item: DataItem)=> void | - | - |
| prefix | 前缀内容 | string \| ReactNode | - | - |
| suffix | 后缀内容 | string \| ReactNode | - | - |
-| trigger | 下拉菜单触发方式 | string \| string [] | 'click' \| 'contextmenu' \| 'hover' | 'click' |
+| trigger | 下拉菜单触发方式 | string \| string [] | 'click' \| 'contextmenu' | 'click' |
## Type
diff --git a/package.json b/package.json
index eb81a22ac..5d3d9d787 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@hi-ui/hiui",
- "version": "2.2.0",
+ "version": "2.2.1",
"description": "HIUI for React",
"scripts": {
"test": "node_modules/.bin/standard && node_modules/.bin/stylelint --config .stylelintrc 'components/**/*.scss'",