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): [Tree] content whit long text align-right issue, close #4689 #4723

Merged
merged 6 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
59 changes: 59 additions & 0 deletions components/tree/__tests__/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,65 @@ describe('Tree', () => {
assertTree({ children: loop(dataSource), dataSource }, mountNode);
});

it.only('should switcher ignore flex when node is long text', () => {
seven-lh marked this conversation as resolved.
Show resolved Hide resolved
const x = 3;
const y = 2;
const z = 1;
const gData = [];

const generateData = (_level, _preKey, _tns) => {
const preKey = _preKey || '0';
const tns = _tns || gData;

const children = [];
for (let i = 0; i < x; i++) {
let key = `${preKey}-${i}`;
key = key === '0-0-0-1' ? '我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的我内容超长的': key;

tns.push({ label: key, key });

if (i < y) {
children.push(key);
}
}

if (_level < 0) {
return tns;
}

const level = _level - 1;
children.forEach((key, index) => {
tns[index].children = [];
return generateData(level, key, tns[index].children);
});
};

generateData(z);
const loop = data =>
data.map(item => {
if (item.children) {
return (
<TreeNode key={item.key} label={item.key}>
{loop(item.children)}
</TreeNode>
);
}
return <TreeNode key={item.key} label={item.key} />;
});
ReactDOM.render(
<Tree
selectable={false}
isLabelBlock
defaultExpandedKeys={['0-0', '0-0-0', '0-0-0-0']}
>
{loop(gData)}
</Tree>,
mountNode
);
const switcherList = document.querySelectorAll('.next-tree-switcher');
assert(Array.from(switcherList).every((v)=>v.clientWidth !== 0));
});

it('should ignore children contain null or string', () => {
ReactDOM.render(
<Tree checkable editable defaultExpandAll defaultSelectedKeys={['1']} defaultCheckedKeys={['3']}>
Expand Down
1 change: 1 addition & 0 deletions components/tree/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
}

&-switcher.#{$css-prefix}noop-noline {
flex: none;
width: $tree-switch-arrow-size;
height: $tree-switch-arrow-size;
}
Expand Down