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(TreeSelect): add className option #4671

Merged
merged 1 commit into from Oct 10, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/tree-select/README.md
Expand Up @@ -145,6 +145,8 @@ In every tree object, `text` property defines `id` stands for the unique key whi
info: 3,
// Whether to show red dot
dot: true,
// ClassName of parent node
className: 'my-class',
// leaves of this parent node
children: [
{
Expand Down
2 changes: 2 additions & 0 deletions src/tree-select/README.zh-CN.md
Expand Up @@ -151,6 +151,8 @@ export default {
info: 3,
// 是否在导航名称右上角显示小红点
dot: true,
// 导航节点额外类名
className: 'my-class',
// 该导航下所有的可选项
children: [
{
Expand Down
3 changes: 2 additions & 1 deletion src/tree-select/index.tsx
Expand Up @@ -13,6 +13,7 @@ export type TreeSelectItem = {
dot?: boolean;
info?: string | number;
disabled?: boolean;
className?: any;
children: TreeSelectChildren[];
};

Expand Down Expand Up @@ -62,7 +63,7 @@ function TreeSelect(
info={item.info}
title={item.text}
disabled={item.disabled}
class={bem('nav-item')}
class={[bem('nav-item'), item.className]}
/>
));

Expand Down
19 changes: 18 additions & 1 deletion src/tree-select/test/index.spec.js
Expand Up @@ -262,7 +262,6 @@ test('max prop', () => {
data() {
return {
activeId: [],
mainActiveIndex: 0,
items: [
{
text: 'group1',
Expand All @@ -278,3 +277,21 @@ test('max prop', () => {
items.at(1).trigger('click');
expect(wrapper.vm.activeId).toEqual([mockItem.id]);
});

test('className of nav', () => {
const wrapper = mount(TreeSelect, {
propsData: {
mainActiveIndex: 0,
items: [
{
text: 'group1',
className: 'my-class',
children: []
}
]
}
});

const items = wrapper.findAll('.van-tree-select__nav-item');
expect(items.at(0).element.classList.contains('my-class')).toBeTruthy();
});