Skip to content

Commit

Permalink
fix(pro:tree): empty state is not centered (#1394)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzaijiang committed Jan 11, 2023
1 parent 1457cfd commit 2c58ca2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
Expand Up @@ -687,7 +687,7 @@ exports[`Tree > render work 1`] = `
`;
exports[`Tree > searchFn work 1`] = `
"<div class=\\"ix-tree ix-tree-active\\" role=\\"tree\\">
"<div class=\\"ix-tree ix-tree-active ix-tree-empty\\" role=\\"tree\\">
<!----><input style=\\"width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;\\" tabindex=\\"0\\" aria-label=\\"for screen reader\\">
<div class=\\"ix-empty ix-empty-simple\\">
<div class=\\"ix-empty-image\\"><svg width=\\"80\\" height=\\"60\\" viewBox=\\"0 0 80 60\\" xmlns=\\"http://www.w3.org/2000/svg\\">
Expand Down Expand Up @@ -891,7 +891,7 @@ exports[`Tree > searchValue work 2`] = `
`;
exports[`Tree > searchValue work 3`] = `
"<div class=\\"ix-tree ix-tree-active\\" role=\\"tree\\">
"<div class=\\"ix-tree ix-tree-active ix-tree-empty\\" role=\\"tree\\">
<!----><input style=\\"width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;\\" tabindex=\\"0\\" aria-label=\\"for screen reader\\">
<div class=\\"ix-empty ix-empty-simple\\">
<div class=\\"ix-empty-image\\"><svg width=\\"80\\" height=\\"60\\" viewBox=\\"0 0 80 60\\" xmlns=\\"http://www.w3.org/2000/svg\\">
Expand Down
2 changes: 2 additions & 0 deletions packages/components/tree/__tests__/tree.spec.ts
Expand Up @@ -664,6 +664,7 @@ describe('Tree', () => {
props: { dataSource: [], empty: { description: emptyDescription } },
})

expect(wrapper.classes()).toContain('ix-tree-empty')
expect(wrapper.find('.ix-empty').text()).toBe(emptyDescription)
})

Expand All @@ -673,6 +674,7 @@ describe('Tree', () => {
slots: { empty: () => h(IxEmpty, { description: 'empty slot' }) },
})

expect(wrapper.classes()).toContain('ix-tree-empty')
expect(wrapper.find('.ix-empty-description').text()).toBe('empty slot')
})

Expand Down
1 change: 1 addition & 0 deletions packages/components/tree/src/Tree.tsx
Expand Up @@ -113,6 +113,7 @@ export default defineComponent({
[`${prefixCls}-auto-height`]: autoHeight.value,
[`${prefixCls}-focused`]: focused.value,
[`${prefixCls}-show-line`]: mergedShowLine.value,
[`${prefixCls}-empty`]: !flattedNodes.value.length,
}
})

Expand Down
6 changes: 6 additions & 0 deletions packages/components/tree/style/index.less
Expand Up @@ -131,6 +131,12 @@
}
}

&.@{tree-prefix}-empty {
display: flex;
align-items: center;
justify-content: center;
}

.@{tree-node-prefix} {
position: relative;
display: flex;
Expand Down

0 comments on commit 2c58ca2

Please sign in to comment.