Skip to content

Commit

Permalink
fix: 修复 Select 组件创建选项输入空内容后不触发 onCreate 的问题 (#2164)
Browse files Browse the repository at this point in the history
* fix: 修复 `Select` 组件创建选项输入空内容后不触发 onCreate 的问题

---------

Co-authored-by: 颜宇浩 <yanyuhao@shein.com>
  • Loading branch information
KMS-Bismarck and 颜宇浩 authored Dec 20, 2024
1 parent 9ad7256 commit eac1dcb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shineout",
"version": "2.0.26",
"version": "2.0.27-beta.1",
"description": "Shein 前端组件库",
"main": "./lib/index.js",
"module": "./es/index.js",
Expand Down
4 changes: 4 additions & 0 deletions site/pages/documentation/changelog/2.x.x.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 更新日志

### 2.0.27-beta.1

- 修复 `Select` 组件创建选项输入空内容后不触发 onCreate 的问题 (< 2.0.27)

### 2.0.26

- 修复 Cascader 开启 final hover-only 且多选的情况下 hover-only 失效的问题 (< 2.0.26)
Expand Down
4 changes: 2 additions & 2 deletions src/Select/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,21 @@ export default <Item, Value>(Origin: React.ComponentType<SelectPropsWidthTiled<I

handleFilter(text: string, from = 'edit') {
const { filterDelay, onFilter, onCreate } = this.props

this.setState({ text })
// not filter
if (!text) {
this.setState({ filterText: '', innerFilter: undefined, innerData: undefined })
if (this.timer) clearTimeout(this.timer)
if (onFilter) onFilter(text, from)
return
}

if (onCreate) {
const innerData = this.handleCreate(text)
this.setState({ innerData })
}

if (!text) return

if (!onFilter) return

this.setState({ filterText: text })
Expand Down

0 comments on commit eac1dcb

Please sign in to comment.