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

[fix] tree 组件完善过滤样式和虚拟滚动样式 #2209

Merged
merged 101 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
a36e8ac
fix(tree): 解决 tree 组件指定 keys 属性后,next 版本可能导致 dom 无限刷新的问题
TabSpace May 5, 2022
f29481f
Merge remote-tracking branch 'upstream/develop' into develop
TabSpace Aug 17, 2022
0ecd815
fix(tree): 解决 tree 组件指定 keys 属性后,next 版本可能导致 dom 无限刷新的问题
TabSpace May 5, 2022
a1db603
Merge branch 'develop' of github.com:TabSpace/tdesign-vue into develop
TabSpace Sep 11, 2022
bf57645
test(tree): 迁移 keys 校验脚本到组件目录内部
TabSpace Sep 11, 2022
bf7a612
docs(tree): 完善调试文档
TabSpace Sep 11, 2022
664c67b
test(tree): tree组件属性变更示例,用随机时间戳作为属性变更例子
TabSpace Sep 12, 2022
8b505cf
test(tree): tree 组件单元测试文件命名规范化
TabSpace Sep 12, 2022
fa94bc9
test(tree): 改进测试代码传参方式,完善代码注释
TabSpace Sep 12, 2022
e385990
test(tree): 完善组件单元测试,提供对公共 api 的单元测试代码
TabSpace Sep 12, 2022
af5f497
test(tree): tree 组件,完善节点插入方法的单元测试
TabSpace Sep 13, 2022
e83e057
refactor(tree): 提取 store, cache 相关方法到 composition api
TabSpace Sep 19, 2022
43b33d4
refactor(tree): tree 组件 composition api 重构,添加原先的公共方法
TabSpace Sep 19, 2022
0a8e9eb
refactor(tree): tree 组件重新实现空数据与类名的生成
TabSpace Oct 8, 2022
e681870
refactor(tree): tree组件提取节点创建方法到 composition api
TabSpace Oct 8, 2022
41d7464
refactor(tree): tree 组件 composition api 实现节点呈现
TabSpace Oct 8, 2022
7f03e64
refactor(tree): tree 组件,迁移主要节点操作逻辑到 composition api
TabSpace Oct 12, 2022
18a5213
refactor(tree): tree 组件,完善监听逻辑的重构
TabSpace Oct 12, 2022
d9e2f47
refactor(tree): tree 组件,移除调试用的注释代码
TabSpace Oct 12, 2022
d9faa8c
refactor(tree): tree 组件,完成基本 composition api 重构,细节还有待调试
TabSpace Oct 13, 2022
18931dd
refactor(tree): tree 组件重构解决操作区域未渲染的问题
TabSpace Oct 13, 2022
5ec4934
refactor(tree): td-tree 组件 composition api 重构通过单元测试
TabSpace Oct 14, 2022
96bf4e0
refactor(tree): tree-item 组件重构为 composition api , 实现基础渲染逻辑抽离
TabSpace Oct 17, 2022
2679734
refactor(tree): tree-item 组件初步实现列表形式渲染的 composition api 重构
TabSpace Oct 18, 2022
939f1dd
chore(tree): treeItem 组件完成 composition api 基本重构
TabSpace Nov 2, 2022
95f161c
refactor(tree): 移除嵌套布局代码
TabSpace Nov 2, 2022
250f1f3
refactor(tree): 解决单元测试时代码类型报错的问题
TabSpace Nov 2, 2022
44f8486
refactor(tree): tree 组件动画样式完善
TabSpace Nov 3, 2022
feac031
refactor(tree): 更新依赖的 common 组件
TabSpace Nov 3, 2022
3ff4e77
refactor(tree): tree 组件更新 common 依赖
TabSpace Nov 3, 2022
27e614f
chore(tree): tree 组件修改,合并 upstream
TabSpace Nov 3, 2022
2052992
test(tree): tree 组件适配 vitest
TabSpace Nov 3, 2022
871e324
test(tree): tree 组件单测改进,移除 done 方法,替换为 promise api
TabSpace Nov 3, 2022
303b639
chore(tree): merge upsteam
TabSpace Nov 16, 2022
bfff126
refactor(tree): 初步合并拖动功能
TabSpace Nov 16, 2022
8bd6f92
refactor(tree): td-tree 合并 draggable 事件功能
TabSpace Nov 16, 2022
c536036
refactor(tree): 实现节点普通事件的抽离封装
TabSpace Nov 16, 2022
c1a3151
refactor(tree): 封装事件派发方法
TabSpace Nov 16, 2022
7c31401
refactor(tree): tree 组件,进一步拆分逻辑到多个文件,onDrag mixin 变更为 composition api 代码
TabSpace Nov 17, 2022
530b01c
refactor(tree): tree item 组件进一步抽离子组件
TabSpace Nov 17, 2022
62d6975
refactor(tree): 实现拖动能力的 composition api 基本重构,有待调试
TabSpace Nov 17, 2022
651c536
refactor(tree): 实现取得节点 dom
TabSpace Nov 17, 2022
98907eb
refactor(tree): 更新 _common 依赖
TabSpace Nov 21, 2022
200fb88
refactor(tree): 实现对接拖动排序逻辑
TabSpace Nov 23, 2022
6dcb193
refactor(tree): 完善拖动,修复动画与图标偏移
TabSpace Nov 23, 2022
b3d1d0b
refactor(tree): 改进上层属性传递方式
TabSpace Nov 23, 2022
89b0a3a
refactor(tree): tree 组件重构,解决过滤结果为空时空列表状态未呈现的问题
TabSpace Nov 23, 2022
f0c65d3
Merge remote-tracking branch 'upstream/develop' into develop
TabSpace Nov 23, 2022
dc14a35
refactor(tree): 更新 src/_common
TabSpace Nov 23, 2022
85e9f91
fix(tree): 解决依赖缺失的问题
TabSpace Nov 23, 2022
96a05ed
chore(tree): 更新 src/_common
TabSpace Nov 25, 2022
36f170a
Merge remote-tracking branch 'upstream/develop' into develop
TabSpace Nov 25, 2022
6d0f0e1
chore(tree): 更新 src/_common
TabSpace Nov 25, 2022
8c8e991
chore(tree): 更新 src/_common
TabSpace Nov 25, 2022
ea4aec2
Merge remote-tracking branch 'upstream/develop' into develop
TabSpace Dec 26, 2022
b2ddd46
fix(tree): 修正动态改变 data 时,视图绑定丢失的问题
TabSpace Dec 28, 2022
fedb755
test(tree): tree 组件,解决 data change 问题后,空列表测试需做相应改造
TabSpace Dec 28, 2022
346eeb0
refactor(tree): 初步添加虚拟滚动部分逻辑
TabSpace Jan 9, 2023
80fb85c
feat(tree): tree 组件添加虚拟滚动基本逻辑
TabSpace Feb 13, 2023
cd1a582
fix(tree): 完善 tree 组件示例样式,完善虚拟滚动配置
TabSpace Feb 14, 2023
d5536f6
fix(tree): tree 完善虚拟滚动逻辑
TabSpace Feb 16, 2023
d02e320
fix(tree): tree组件,虚拟滚动应当只渲染可见节点
TabSpace Feb 16, 2023
010550b
fix(tree): tree 组件完善虚拟滚动,添加子节点通知组件更新高度的逻辑
TabSpace Feb 16, 2023
a048657
fix(tree): tree 组件梳理 hooks 公共依赖,整合到统一对象进行管理
TabSpace Feb 17, 2023
a542404
fix(tree): tree 组件解决虚拟滚动状态判断不准确的问题
TabSpace Feb 17, 2023
a539eba
fix(tree): 解决虚拟滚动状态下,动画导致滚动异常的问题
TabSpace Feb 20, 2023
9d16f60
fix(tree): tree 组件,改进列表渲染,key 改为使用私有的独立 id,避免被业务数据干扰
TabSpace Feb 20, 2023
96607ea
fix(tree): 改进 tree 组件渲染方式,使用私有 key 控制缓存
TabSpace Feb 20, 2023
fc4b488
test(tree): 完善虚拟滚动示例,添加更多视图操作
TabSpace Feb 20, 2023
dfdf028
fix(tree): tree 组件完善虚拟滚动样式注入时机
TabSpace Feb 21, 2023
c9ef81d
fix(tree): 解决 tree 组件虚拟滚动并开启动画时卡顿的问题
TabSpace Feb 21, 2023
465292a
fix(tree): tree 组件解决属性 allowFoldNodeOnFilter 未生效的问题
TabSpace Feb 23, 2023
35a124f
fix(tree): tree 组件,改进关闭动画时,判断不使用 transition-group 的时机
TabSpace Feb 23, 2023
d480428
fix(tree): tree 组件初步接入 虚拟滚动的 lazy 模式
TabSpace Feb 24, 2023
92f602c
fix(tree): tree 组件虚拟滚动实现 lazy 模式
TabSpace Feb 24, 2023
105a1b8
fix(tree): tree 组件完善虚拟滚动属性传递
TabSpace Feb 24, 2023
494cda4
test(tree): tree 组件,解决测试中出现用例告警的问题
TabSpace Feb 24, 2023
fe964a5
chore(tree): merge upstream
TabSpace Feb 24, 2023
fc94c8d
fix(tree): tree 组件,完善过滤示例,解决直接设置属性未生效的问题
TabSpace Feb 28, 2023
f644c18
test(tree): tree 组件完善单元测试,直接设置expanded, actived, checked属性时,视图应当有相应变化
TabSpace Feb 28, 2023
df81183
test(tree): tree 组件,完善 api 方法的单元测试
TabSpace Feb 28, 2023
f01a2c8
fix(tree): tree 组件更新对 common 的依赖
TabSpace Feb 28, 2023
30c92b2
fix(tree): tree 组件更新对 common 的依赖
TabSpace Feb 28, 2023
7997bdd
docs(tree): tree 组件添加虚拟滚动示例
TabSpace Feb 28, 2023
56c0b3f
chore(tree): tree 组件更新 common 依赖
TabSpace Feb 28, 2023
3afae34
chore(tree): tree 组件 merge upstream
TabSpace Feb 28, 2023
05f9b57
fix(tree): tree 组件完善 vscroll 示例
TabSpace Mar 1, 2023
0979152
fix(tree): tree 组件,修正 common 依赖
TabSpace Mar 1, 2023
bd7e70a
fix(tree): tree 组件,类型名称规范化
TabSpace Mar 3, 2023
e2cb183
fix(tree): tree 组件,修正虚拟滚动示例未能切换到普通模式的问题
TabSpace Mar 3, 2023
6ca49d8
fix(tree): tree 组件,过滤且允许折叠时,完善呈现样式
TabSpace Mar 3, 2023
bbdfa59
fix(tree): tree 组件,规范化属性类型
TabSpace Mar 3, 2023
490cd2a
chore(tree): tree 组件,更新 common 依赖
TabSpace Mar 3, 2023
cc1f973
chore(tree): tree 组件,merge upstream/develop
TabSpace Mar 3, 2023
a04ede3
chore(tree): tree 组件,更新 common 依赖
TabSpace Mar 3, 2023
9689ea6
fix(tree): tree 组件完善事件参数,提供 trigger 属性
TabSpace Mar 6, 2023
97db7e7
test(tree): tree 组件添加单元测试,完善对 activable 状态的检查
TabSpace Mar 6, 2023
6937907
test(tree): tree 组件完善 activable 能力的单元测试
TabSpace Mar 6, 2023
01b05a8
chore(tree): tree 组件,更新 common 依赖
TabSpace Mar 6, 2023
a1649f2
fix(tree-select): tree-select 修正代码中的传递类型错误
TabSpace Mar 6, 2023
805cec8
Merge remote-tracking branch 'upstream/develop' into develop
TabSpace Mar 6, 2023
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 src/_common
Submodule _common updated 76 files
+31 −0 docs/web/api/back-top.md
+3 −0 docs/web/api/image.md
+6 −3 js/tree/tree-node.ts
+182 −160 style/mobile/_variables.less
+1 −1 style/mobile/components/action-sheet/_index.less
+1 −1 style/mobile/components/action-sheet/_var.less
+4 −4 style/mobile/components/avatar/_var.less
+2 −2 style/mobile/components/back-top/_index.less
+2 −2 style/mobile/components/back-top/_var.less
+1 −1 style/mobile/components/badge/_index.less
+1 −1 style/mobile/components/badge/_var.less
+1 −1 style/mobile/components/button-group/_index.less
+1 −1 style/mobile/components/button-group/_var.less
+5 −5 style/mobile/components/button/_index.less
+16 −19 style/mobile/components/button/_var.less
+5 −5 style/mobile/components/calendar/_index.less
+6 −6 style/mobile/components/cascader/_var.less
+3 −3 style/mobile/components/cell-group/_var.less
+7 −7 style/mobile/components/cell/_index.less
+2 −2 style/mobile/components/cell/_var.less
+1 −1 style/mobile/components/checkbox/_index.less
+5 −5 style/mobile/components/checkbox/_var.less
+7 −7 style/mobile/components/collapse/_var.less
+5 −5 style/mobile/components/count-down/_var.less
+2 −2 style/mobile/components/dialog/_index.less
+18 −18 style/mobile/components/dialog/_var.less
+1 −1 style/mobile/components/dropdown-menu/_index.less
+8 −8 style/mobile/components/dropdown-menu/_var.less
+1 −1 style/mobile/components/fab/_index.less
+1 −1 style/mobile/components/grid-item/_var.less
+2 −2 style/mobile/components/image/_index.less
+1 −1 style/mobile/components/image/_var.less
+2 −2 style/mobile/components/indexes/_var.less
+1 −1 style/mobile/components/input/_index.less
+6 −6 style/mobile/components/input/_var.less
+1 −1 style/mobile/components/loading/_var.less
+1 −1 style/mobile/components/message/_index.less
+2 −2 style/mobile/components/message/_var.less
+1 −1 style/mobile/components/navbar/_index.less
+1 −1 style/mobile/components/navbar/_var.less
+5 −5 style/mobile/components/notice-bar/_index.less
+2 −2 style/mobile/components/notice-bar/_var.less
+9 −9 style/mobile/components/picker/_index.less
+1 −1 style/mobile/components/pull-down-refresh/_var.less
+2 −2 style/mobile/components/radio/_index.less
+7 −7 style/mobile/components/radio/_var.less
+2 −2 style/mobile/components/rate/_var.less
+2 −2 style/mobile/components/result/_index.less
+3 −3 style/mobile/components/result/_var.less
+3 −3 style/mobile/components/search/_index.less
+9 −9 style/mobile/components/search/_var.less
+5 −5 style/mobile/components/slider/_index.less
+8 −8 style/mobile/components/slider/_var.less
+4 −4 style/mobile/components/stepper/_var.less
+6 −6 style/mobile/components/steps/_index.less
+13 −13 style/mobile/components/steps/_mixin.less
+2 −2 style/mobile/components/swiper/_index.less
+5 −5 style/mobile/components/switch/_var.less
+4 −4 style/mobile/components/tab-bar/_var.less
+4 −4 style/mobile/components/tabs/_var.less
+72 −59 style/mobile/components/tag/_index.less
+51 −56 style/mobile/components/tag/_var.less
+6 −6 style/mobile/components/textarea/_var.less
+9 −9 style/mobile/components/toast/_index.less
+1 −1 style/mobile/components/toast/_var.less
+1 −1 style/mobile/components/upload/_index.less
+27 −27 style/mobile/components/upload/_var.less
+5 −5 style/mobile/mixins/_hairline.less
+1 −0 style/web/_variables.less
+2 −0 style/web/components/_index.less
+76 −0 style/web/components/back-top/_index.less
+41 −0 style/web/components/back-top/_mixin.less
+49 −0 style/web/components/back-top/_var.less
+1 −1 style/web/components/guide/_index.less
+1 −1 style/web/components/image-viewer/_index.less
+16 −0 style/web/components/tree/_index.less
7 changes: 5 additions & 2 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export interface HTMLElementAttributes {
[css: string]: string;
}

export interface InfinityScroll {
export interface TScroll {
/**
* 表示除可视区域外,额外渲染的行数,避免快速滚动过程中,新出现的内容来不及渲染从而出现空白
* @default 20
Expand All @@ -99,4 +99,7 @@ export interface InfinityScroll {
type: 'lazy' | 'virtual';
}

export type TScroll = InfinityScroll;
/**
* @deprecated use TScroll instead
*/
export type InfinityScroll = TScroll;
5 changes: 4 additions & 1 deletion src/tree-select/useTreeSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ export default function useTreeSelect(props: TdTreeSelectProps, context: SetupCo
current = isObjectValue.value ? treeRef.value.getItem(nodeValue) : nodeValue;
if (!onlyLeafNode) {
setTreeSelectValue(current, { ...ctx, data: ctx.node.data, trigger: 'check' });
setInnerVisible(false, ctx);
setInnerVisible(false, {
e: ctx.e,
trigger: 'trigger-element-click',
});
}
innerInputValue.value && setInnerInputValue('', { trigger: 'change', e: ctx.e });
};
Expand Down
266 changes: 266 additions & 0 deletions src/tree/__tests__/activable.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
import { mount } from '@vue/test-utils';
import Tree from '@/src/tree/index.ts';
import { delay } from './kit';

describe('Tree:activable', () => {
vi.useRealTimers();
describe('props.activable', () => {
it('设置 activable 为 true, 节点可以具有激活态', async () => {
const data = [
{
value: 't1',
children: [
{
value: 't1.1',
},
{
value: 't1.2',
},
],
},
];
const wrapper = mount({
render() {
return <Tree ref="tree" data={data} activable expand-all transition={false}></Tree>;
},
});
await delay(1);
const { tree } = wrapper.vm.$refs;
tree.setItem('t1.1', {
actived: true,
});
await delay(1);
expect(wrapper.find('[data-value="t1"]').classes('t-is-active')).toBe(false);
expect(wrapper.find('[data-value="t1.1"]').classes('t-is-active')).toBe(true);
expect(wrapper.find('[data-value="t1.2"]').classes('t-is-active')).toBe(false);
tree.setItem('t1.1', {
actived: false,
});
await delay(1);
expect(wrapper.find('[data-value="t1"]').classes('t-is-active')).toBe(false);
expect(wrapper.find('[data-value="t1.1"]').classes('t-is-active')).toBe(false);
expect(wrapper.find('[data-value="t1.2"]').classes('t-is-active')).toBe(false);
});

it('在 data 中可以预先设置激活态', async () => {
const data = [
{
value: 't1',
children: [
{
value: 't1.1',
actived: true,
},
{
value: 't1.2',
actived: true,
},
],
},
];
const wrapper = mount({
render() {
return <Tree ref="tree" data={data} activable expand-all transition={false}></Tree>;
},
});
await delay(1);
expect(wrapper.find('[data-value="t1"]').classes('t-is-active')).toBe(false);
expect(wrapper.find('[data-value="t1.1"]').classes('t-is-active')).toBe(true);
expect(wrapper.find('[data-value="t1.2"]').classes('t-is-active')).toBe(true);
});
});

describe('props.defaultActived', () => {
it('defaultActived 可以用来设置默认激活状态', async () => {
const data = [
{
value: 't1',
children: [
{
value: 't1.1',
},
{
value: 't1.2',
},
],
},
];
const wrapper = mount({
render() {
return <Tree ref="tree" data={data} activable defaultActived={['t1.1']} expand-all transition={false}></Tree>;
},
});
await delay(1);
expect(wrapper.find('[data-value="t1"]').classes('t-is-active')).toBe(false);
expect(wrapper.find('[data-value="t1.1"]').classes('t-is-active')).toBe(true);
expect(wrapper.find('[data-value="t1.2"]').classes('t-is-active')).toBe(false);
});
});

describe('props.actived', () => {
it('设置 actived 可指定激活节点', async () => {
const data = [
{
value: 't1',
children: [
{
value: 't1.1',
},
{
value: 't1.2',
},
],
},
];
const wrapper = mount({
render() {
return <Tree ref="tree" data={data} activable actived={['t1.1']} expand-all transition={false}></Tree>;
},
});
await delay(1);
expect(wrapper.find('[data-value="t1"]').classes('t-is-active')).toBe(false);
expect(wrapper.find('[data-value="t1.1"]').classes('t-is-active')).toBe(true);
expect(wrapper.find('[data-value="t1.2"]').classes('t-is-active')).toBe(false);
});

it('设置 actived 可变更激活节点', async () => {
const data = [
{
value: 't1',
children: [
{
value: 't1.1',
},
{
value: 't1.2',
},
],
},
];
const wrapper = mount({
data() {
return {
actived: ['t1.1'],
};
},
render() {
return <Tree ref="tree" data={data} activable actived={this.actived} expand-all transition={false}></Tree>;
},
});
await delay(1);
expect(wrapper.find('[data-value="t1"]').classes('t-is-active')).toBe(false);
expect(wrapper.find('[data-value="t1.1"]').classes('t-is-active')).toBe(true);
expect(wrapper.find('[data-value="t1.2"]').classes('t-is-active')).toBe(false);
wrapper.setData({
actived: ['t1.2'],
});
await delay(1);
expect(wrapper.find('[data-value="t1"]').classes('t-is-active')).toBe(false);
expect(wrapper.find('[data-value="t1.1"]').classes('t-is-active')).toBe(false);
expect(wrapper.find('[data-value="t1.2"]').classes('t-is-active')).toBe(true);
wrapper.setData({
actived: ['t1'],
});
await delay(1);
expect(wrapper.find('[data-value="t1"]').classes('t-is-active')).toBe(true);
expect(wrapper.find('[data-value="t1.1"]').classes('t-is-active')).toBe(false);
expect(wrapper.find('[data-value="t1.2"]').classes('t-is-active')).toBe(false);
});
});

describe('props.activeMultiple', () => {
it('默认激活其他节点,原激活节点要取消激活状态', async () => {
const data = [
{
value: 't1',
actived: true,
children: [
{
value: 't1.1',
},
{
value: 't1.2',
},
],
},
];
const wrapper = mount({
render() {
return <Tree ref="tree" data={data} activable expand-all transition={false}></Tree>;
},
});
await delay(1);
const { tree } = wrapper.vm.$refs;

expect(wrapper.find('[data-value="t1"]').classes('t-is-active')).toBe(true);
expect(wrapper.find('[data-value="t1.1"]').classes('t-is-active')).toBe(false);
expect(wrapper.find('[data-value="t1.2"]').classes('t-is-active')).toBe(false);

tree.setItem('t1.1', {
actived: true,
});

await delay(1);

expect(wrapper.find('[data-value="t1"]').classes('t-is-active')).toBe(false);
expect(wrapper.find('[data-value="t1.1"]').classes('t-is-active')).toBe(true);
expect(wrapper.find('[data-value="t1.2"]').classes('t-is-active')).toBe(false);

tree.setItem('t1.2', {
actived: true,
});
await delay(1);

expect(wrapper.find('[data-value="t1"]').classes('t-is-active')).toBe(false);
expect(wrapper.find('[data-value="t1.1"]').classes('t-is-active')).toBe(false);
expect(wrapper.find('[data-value="t1.2"]').classes('t-is-active')).toBe(true);
});

it('设置 activeMultiple 为 true,节点激活状态互不关联', async () => {
const data = [
{
value: 't1',
actived: true,
children: [
{
value: 't1.1',
},
{
value: 't1.2',
},
],
},
];
const wrapper = mount({
render() {
return <Tree ref="tree" data={data} activable expand-all activeMultiple={true} transition={false}></Tree>;
},
});
await delay(1);
const { tree } = wrapper.vm.$refs;

expect(wrapper.find('[data-value="t1"]').classes('t-is-active')).toBe(true);
expect(wrapper.find('[data-value="t1.1"]').classes('t-is-active')).toBe(false);
expect(wrapper.find('[data-value="t1.2"]').classes('t-is-active')).toBe(false);

tree.setItem('t1.1', {
actived: true,
});

await delay(1);

expect(wrapper.find('[data-value="t1"]').classes('t-is-active')).toBe(true);
expect(wrapper.find('[data-value="t1.1"]').classes('t-is-active')).toBe(true);
expect(wrapper.find('[data-value="t1.2"]').classes('t-is-active')).toBe(false);

tree.setItem('t1.2', {
actived: true,
});
await delay(1);

expect(wrapper.find('[data-value="t1"]').classes('t-is-active')).toBe(true);
expect(wrapper.find('[data-value="t1.1"]').classes('t-is-active')).toBe(true);
expect(wrapper.find('[data-value="t1.2"]').classes('t-is-active')).toBe(true);
});
});
});
6 changes: 6 additions & 0 deletions src/tree/_example/activable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,29 @@ export default {
expandOnClickNode: false,
items: [
{
value: 't1',
label: '1',
children: [
{
value: 't1.1',
label: '1.1',
},
{
value: 't1.2',
label: '1.2',
},
],
},
{
value: 't2',
label: '2',
children: [
{
value: 't2.1',
label: '2.1',
},
{
value: 't2.2',
label: '2.2',
},
],
Expand Down
13 changes: 10 additions & 3 deletions src/tree/_example/filter.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<template>
<t-space :size="32" direction="vertical">
<t-form labelWidth="150">
<t-input-adornment prepend="filter:">
<t-input v-model="filterText" @change="onInput" />
</t-input-adornment>
<t-form-item label="">
<t-input-adornment prepend="filter:">
<t-input v-model="filterText" @change="onInput" />
</t-input-adornment>
</t-form-item>
<t-form-item label="允许折叠">
<t-switch v-model="allowFoldNodeOnFilter" @change="checkExpanded" />
</t-form-item>
<t-form-item label="可选">
<t-switch v-model="isCheckable" />
</t-form-item>
</t-form>
<t-tree
ref="tree"
Expand All @@ -16,6 +21,7 @@
:allowFoldNodeOnFilter="allowFoldNodeOnFilter"
:default-expanded="expanded"
:filter="filterByText"
:checkable="isCheckable"
hover
line
/>
Expand Down Expand Up @@ -117,6 +123,7 @@ const exampleItems = [
export default {
data() {
return {
isCheckable: false,
filterText: '',
filterByText: null,
expanded: ['1.1.1'],
Expand Down
5 changes: 4 additions & 1 deletion src/tree/_example/vscroll.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default {
computed: {
scroll() {
const { scrollMode } = this;
if (!scrollMode === 'normal') {
if (scrollMode === 'normal') {
return null;
}
const scrollProps = {
Expand Down Expand Up @@ -195,4 +195,7 @@ export default {
.tdesign-demo-vscroll .t-alert {
margin-bottom: 5px;
}
.tdesign-demo-vscroll .t-tree {
overflow-y: auto;
}
</style>
Loading