Skip to content

Commit

Permalink
Fix: tree-select empty text 显示异常 & onClear 后value 重置问题 (#1903)
Browse files Browse the repository at this point in the history
* fix(tree &treeselect): empty data on tree component visible

* fix(tree-select): fix onClear

* feat: snap
  • Loading branch information
genyuMPj authored Jan 17, 2023
1 parent 815a744 commit 575067b
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/tree-select/TreeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const TreeSelect = forwardRef((props: TreeSelectProps, ref) => {

const handleClear = usePersistFn<SelectInputProps['onClear']>((ctx) => {
ctx.e.stopPropagation();
onChange(multiple ? [] : formatValue(null), {
onChange(multiple ? [] : formatValue(undefined), {
node: null,
trigger: 'clear',
e: ctx.e as React.MouseEvent<any, any>,
Expand Down
1 change: 0 additions & 1 deletion src/tree-select/defaultProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const treeSelectDefaultProps: TdTreeSelectProps = {
borderless: false,
clearable: false,
data: [],
empty: '',
filterable: false,
loading: false,
max: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/tree-select/tree-select.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ clearable | Boolean | false | 是否允许清空 | N
collapsedItems | TElement | - | 多选情况下,用于设置折叠项内容,默认为 `+N`。如果需要悬浮就显示其他内容,可以使用 collapsedItems 自定义。TS 类型:`TNode<{ value: DataOption[]; collapsedSelectedItems: DataOption[]; count: number }>`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
data | Array | [] | 数据。TS 类型:`Array<DataOption>` | N
disabled | Boolean | - | 是否禁用组件 | N
empty | TNode | '' | 当下拉列表为空时显示的内容。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
empty | TNode | '-' | 当下拉列表为空时显示的内容。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
filter | Function | - | 过滤方法,用于对现有数据进行搜索过滤,判断是否过滤某一项数据。TS 类型:`(filterWords: string, option: DataOption) => boolean` | N
filterable | Boolean | false | 是否可搜索 | N
inputProps | Object | - | 透传给 输入框 Input 组件的全部属性。TS 类型:`InputProps`[Input API Documents](./input?tab=api)[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/tree-select/type.ts) | N
Expand Down
1 change: 0 additions & 1 deletion src/tree-select/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export interface TdTreeSelectProps<DataOption extends TreeOptionData = TreeOptio
disabled?: boolean;
/**
* 当下拉列表为空时显示的内容
* @default ''
*/
empty?: TNode;
/**
Expand Down
1 change: 0 additions & 1 deletion src/tree/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ Tree.displayName = 'Tree';

Tree.defaultProps = {
data: [],
empty: '',
expandLevel: 0,
icon: true,
line: false,
Expand Down
2 changes: 1 addition & 1 deletion src/tree/tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ data | Array | [] | 树数据,泛型 `T` 表示树节点 TS 类型。TS 类型
disableCheck | Boolean / Function | false | 禁用复选框,可支持禁用不同的行。TS 类型:`boolean \| ((node: TreeNodeModel<T>) => boolean)` | N
disabled | Boolean | - | 是否禁用树操作 | N
draggable | Boolean | - | [开发中]节点是否可拖拽 | N
empty | TNode | '' | 数据为空时展示的文本。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
empty | TNode | '暂无数据' | 数据为空时展示的文本。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
expandAll | Boolean | false | 是否展开全部节点 | N
expandLevel | Number | 0 | 默认展开的级别,第一层为 0 | N
expandMutex | Boolean | false | 同级别展开互斥,手风琴效果 | N
Expand Down
Loading

0 comments on commit 575067b

Please sign in to comment.