Skip to content

Commit

Permalink
Merge pull request #1582 from XiaoMi/hotfix/#1578
Browse files Browse the repository at this point in the history
Hotfix/#1578
  • Loading branch information
Nice-Ming authored Feb 3, 2021
2 parents d71aa4d + 73baf1d commit a1f1f98
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
- 修复 `DatePicker` type 为 week 或者 weekrange 时 输入相应格式日期解析错误问题 [#1579](https://github.com/XiaoMi/hiui/issues/1579)
- 修复 `Preview` 图片预览组件,滚轮放大缩小错误 [#1573](https://github.com/XiaoMi/hiui/issues/1573)
- 修复 `TimePicker` 时间范围选择,为空时无法选择打开弹窗时的当前值 [#1530](https://github.com/XiaoMi/hiui/issues/1530)
- 修复 `Select` 组件在异步多选时,关闭弹层下拉选项内容丢失问题 [#1578](https://github.com/XiaoMi/hiui/issues/1578)
- 优化 `Select` 组件异步类型时候,searchable 属性可控制筛选框的显示隐藏 [#1577](https://github.com/XiaoMi/hiui/issues/1577)

## 3.4.0

Expand Down
7 changes: 5 additions & 2 deletions components/select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const InternalSelect = (props) => {
bordered = true
} = props
const selectInputContainer = useRef()
const autoloadFlag = useRef(autoload) // 多选情况下,需要记录是否进行了筛选
const historyData = useRef([])
const [dropdownItems, setDropdownItems] = useState(data)
const [isGroup, setIsGroup] = useState(false)
Expand Down Expand Up @@ -97,7 +98,8 @@ const InternalSelect = (props) => {
}, [keyword, isGroup])

useEffect(() => {
setSearchable(dataSource ? true : propsSearchable)
const dataSourcePropsSearchable = typeof propsSearchable !== 'undefined' ? propsSearchable : true // 在存在dataSource的时候,默认searchable为true
setSearchable(dataSource ? dataSourcePropsSearchable : propsSearchable)
}, [propsSearchable])

useEffect(() => {
Expand Down Expand Up @@ -194,7 +196,7 @@ const InternalSelect = (props) => {
setDropdownShow(false)
}
// 多选具有默认值的话打开的话应该显示选中的值
if (dataSource && type === 'multiple') {
if (dataSource && type === 'multiple' && !autoloadFlag.current) {
setCacheSelectItem(selectedItems)
setDropdownItems(selectedItems)
}
Expand Down Expand Up @@ -649,6 +651,7 @@ const InternalSelect = (props) => {
showCheckAll={showCheckAll}
checkAll={checkAll}
loading={loading}
autoloadFlag={autoloadFlag}
focusedIndex={focusedIndex}
setFocusedIndex={setFocusedIndex}
showJustSelected={showJustSelected}
Expand Down
4 changes: 3 additions & 1 deletion components/select/SelectDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const SelectDropdown = ({
isGroup,
onOverlayScroll,
setFocusedIndex,
targetByKeyDown
targetByKeyDown,
autoloadFlag
}) => {
const [filterItems, setFilterItems] = useState(dropdownItems)
const [searchbarValue, setSearchbarValue] = useState('')
Expand Down Expand Up @@ -124,6 +125,7 @@ const SelectDropdown = ({
const filterText = e.target.value
filterOptions(filterText)
onSearch(filterText)
autoloadFlag.current = false
},
[onSearch]
)
Expand Down

0 comments on commit a1f1f98

Please sign in to comment.