Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Cascader 新增 emptyAfterSelect 属性 #2057

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.10-beta.2",
"version": "2.0.10-beta.3",
"description": "Shein 前端组件库",
"main": "./lib/index.js",
"module": "./es/index.js",
Expand Down
2 changes: 1 addition & 1 deletion site/chunks/Components/Cascader.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion site/chunks/Components/Select.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions site/pages/documentation/changelog/2.x.x.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# 更新日志
`### 2.0.10-beta.3
- Cascader 新增 emptyAfterSelect 属性用于控制多选模式下是否清空筛选输入值

`### 2.0.10-beta.2
- 修复 Datepicker Time 组件丢失时区属性的问题(< 2.0.10)

Expand Down
9 changes: 8 additions & 1 deletion src/Cascader/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ interface Props {
trim: boolean
focus: boolean
filterText: string
emptyAfterSelect?: boolean
multiple: boolean
}

interface State {
Expand Down Expand Up @@ -48,7 +50,12 @@ class FilterInput extends Component<Props, State> {
}

reset() {
if (this.editElement) this.editElement.innerText = ''
const { emptyAfterSelect = true, multiple } = this.props
if (this.editElement) {
if (!(multiple && !emptyAfterSelect)) {
this.editElement.innerText = ''
}
}
if (this.blurTimer) clearTimeout(this.blurTimer)
}

Expand Down
7 changes: 7 additions & 0 deletions src/Cascader/Props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ export interface OriginCascaderProps<DataItem, Value extends CascaderBaseValue>
* @inner 内部属性
*/
trim?: boolean
/**
* @en empty input after select value
* @cn 选中后是否清空输入框内容
* @default true
*/
emptyAfterSelect?: boolean
}

/** ------ filterList ------ * */
Expand Down Expand Up @@ -343,6 +349,7 @@ export interface ResultProps<DataItem, Value extends CascaderBaseValue>
multiple: boolean
bindInput: (Input: any) => void
selectId: string
emptyAfterSelect?: boolean
}

export interface ResultItemProps<DataItem> {
Expand Down
4 changes: 3 additions & 1 deletion src/Cascader/Result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,14 @@ class Result<DataItem, Value extends CascaderBaseValue> extends PureComponent<
}

renderInput() {
const { onFilter, focus, trim, bindInput, filterText } = this.props
const { onFilter, focus, trim, bindInput, filterText, multiple, emptyAfterSelect } = this.props
return (
<Input
filterText={filterText}
ref={bindInput}
trim={!!trim}
multiple={multiple}
emptyAfterSelect={emptyAfterSelect}
key={`input.${focus ? 1 : 0}`}
focus
onFilter={onFilter!}
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import * as utils from './utils'

export default { utils, version: '2.0.10-beta.2' }
export default { utils, version: '2.0.10-beta.3' }
export { utils }
export { setLocale } from './locale'
export { color, style } from './utils/expose'
Expand Down
Loading