Skip to content

Commit 5e27ff8

Browse files
committed
feat: update tree doubleclick to dbclick
1 parent b552450 commit 5e27ff8

File tree

6 files changed

+19
-13
lines changed

6 files changed

+19
-13
lines changed

components/tree/DirectoryTree.jsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import omit from 'omit.js';
22
import debounce from 'lodash/debounce';
33
import PropTypes from '../_util/vue-types';
4+
import warning from '../_util/warning';
45
import { conductExpandParent, convertTreeToEntities } from '../vc-tree/src/util';
56
import Tree, { TreeProps } from './Tree';
67
import { calcRangeKeys, getFullKeyList } from './util';
@@ -9,7 +10,7 @@ import BaseMixin from '../_util/BaseMixin';
910
import { initDefaultProps, getOptionProps } from '../_util/props-util';
1011
import { ConfigConsumerProps } from '../config-provider';
1112

12-
// export type ExpandAction = false | 'click' | 'doubleClick'; export interface
13+
// export type ExpandAction = false | 'click' | 'dbclick'; export interface
1314
// DirectoryTreeProps extends TreeProps { expandAction?: ExpandAction; }
1415
// export interface DirectoryTreeState { expandedKeys?: string[];
1516
// selectedKeys?: string[]; }
@@ -32,7 +33,7 @@ export default {
3233
props: initDefaultProps(
3334
{
3435
...TreeProps(),
35-
expandAction: PropTypes.oneOf([false, 'click', 'doubleclick']),
36+
expandAction: PropTypes.oneOf([false, 'click', 'doubleclick', 'dbclick']),
3637
},
3738
{
3839
showIcon: true,
@@ -103,11 +104,12 @@ export default {
103104
const { expandAction } = this.$props;
104105

105106
// Expand the tree
106-
if (expandAction === 'doubleclick') {
107+
if (expandAction === 'dbclick' || expandAction === 'doubleclick') {
107108
this.onDebounceExpand(event, node);
108109
}
109110

110111
this.$emit('doubleclick', event, node);
112+
this.$emit('dbclick', event, node);
111113
},
112114

113115
onSelect(keys, event) {
@@ -181,6 +183,10 @@ export default {
181183
const getPrefixCls = this.configProvider.getPrefixCls;
182184
const prefixCls = getPrefixCls('tree', customizePrefixCls);
183185
const { _expandedKeys: expandedKeys, _selectedKeys: selectedKeys } = this.$data;
186+
warning(
187+
!this.$listeners.doubleclick,
188+
'`doubleclick` is deprecated. please use `dbclick` instead.',
189+
);
184190
const treeProps = {
185191
props: {
186192
icon: getIcon,
@@ -195,7 +201,7 @@ export default {
195201
...omit(this.$listeners, ['update:selectedKeys']),
196202
select: this.onSelect,
197203
click: this.onClick,
198-
doubleclick: this.onDoubleClick,
204+
dbclick: this.onDoubleClick,
199205
expand: this.onExpand,
200206
},
201207
};

components/tree/index.en-US.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ One of the Tree `treeNode` prop for describing the tree's node, TreeNode has the
6363

6464
### DirectoryTree props
6565

66-
| Property | Description | Type | Default |
67-
| --- | --- | --- | --- |
68-
| expandAction | Directory open logic, optional `false` `'click'` `'doubleclick'` | string | click |
66+
| Property | Description | Type | Default |
67+
| ------------ | ------------------------------------------------------------ | ------ | ------- |
68+
| expandAction | Directory open logic, optional `false` `'click'` `'dbclick'` | string | click |
6969

7070
## FAQ
7171

components/tree/index.zh-CN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@
6363

6464
### DirectoryTree props
6565

66-
| 参数 | 说明 | 类型 | 默认值 |
67-
| ------------ | ---------------------------------------------------- | ------ | ------ |
68-
| expandAction | 目录展开逻辑,可选 `false` `'click'` `'doubleclick'` | string | click |
66+
| 参数 | 说明 | 类型 | 默认值 |
67+
| ------------ | ------------------------------------------------ | ------ | ------ |
68+
| expandAction | 目录展开逻辑,可选 `false` `'click'` `'dbclick'` | string | click |
6969

7070
## FAQ
7171

components/vc-cascader/Menus.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default {
6161
},
6262
on: {
6363
click: onSelect,
64-
doubleclick: onItemDoubleClick,
64+
dbclick: onItemDoubleClick,
6565
mousedown: e => e.preventDefault(),
6666
},
6767
key: Array.isArray(key) ? key.join('__ant__') : key,

components/vc-table/demo/rowAndCellClick.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export default {
116116
customRow={(record, index) => ({
117117
on: {
118118
click: onRowClick.bind(null, record, index),
119-
dblclick: onRowDoubleClick.bind(null, record, index),
119+
dbclick: onRowDoubleClick.bind(null, record, index),
120120
},
121121
})}
122122
/>

components/vc-tree/src/Tree.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ const Tree = {
380380
},
381381

382382
onNodeDoubleClick(e, treeNode) {
383-
this.__emit('doubleclick', e, treeNode);
383+
this.__emit('dbclick', e, treeNode);
384384
},
385385

386386
onNodeSelect(e, treeNode) {

0 commit comments

Comments
 (0)