🐛 Fix List item flex layout (#20897)

close #20648
This commit is contained in:
偏右 2020-01-15 10:35:45 +08:00 committed by afc163
parent 150ca1d49c
commit 9a3640968e
3 changed files with 14 additions and 13 deletions

View File

@ -72,7 +72,7 @@ export default class Item extends React.Component<ListItemProps, any> {
context: any;
isItemContainsTextNode() {
isItemContainsTextNodeAndNotSingular() {
const { children } = this.props;
let result;
React.Children.forEach(children, (element: React.ReactElement<any>) => {
@ -80,7 +80,7 @@ export default class Item extends React.Component<ListItemProps, any> {
result = true;
}
});
return result;
return result && React.Children.count(children) > 1;
}
isFlexMode() {
@ -89,7 +89,7 @@ export default class Item extends React.Component<ListItemProps, any> {
if (itemLayout === 'vertical') {
return !!extra;
}
return !this.isItemContainsTextNode();
return !this.isItemContainsTextNodeAndNotSingular();
}
renderItem = ({ getPrefixCls }: ConfigConsumerProps) => {

View File

@ -764,27 +764,27 @@ exports[`renders ./components/list/demo/simple.md correctly 1`] = `
class="ant-list-items"
>
<li
class="ant-list-item ant-list-item-no-flex"
class="ant-list-item"
>
Racing car sprays burning fuel into crowd.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
class="ant-list-item"
>
Japanese princess to wed commoner.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
class="ant-list-item"
>
Australian walks 100km after outback crash.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
class="ant-list-item"
>
Man charged over missing wedding girl.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
class="ant-list-item"
>
Los Angeles battles huge wildfires.
</li>
@ -824,27 +824,27 @@ exports[`renders ./components/list/demo/simple.md correctly 1`] = `
class="ant-list-items"
>
<li
class="ant-list-item ant-list-item-no-flex"
class="ant-list-item"
>
Racing car sprays burning fuel into crowd.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
class="ant-list-item"
>
Japanese princess to wed commoner.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
class="ant-list-item"
>
Australian walks 100km after outback crash.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
class="ant-list-item"
>
Man charged over missing wedding girl.
</li>
<li
class="ant-list-item ant-list-item-no-flex"
class="ant-list-item"
>
Los Angeles battles huge wildfires.
</li>

View File

@ -66,6 +66,7 @@
&-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: @list-item-padding;
&-content {