diff --git a/components/list/Item.tsx b/components/list/Item.tsx index 1174514359..0edce23ce8 100644 --- a/components/list/Item.tsx +++ b/components/list/Item.tsx @@ -72,7 +72,7 @@ export default class Item extends React.Component { context: any; - isItemContainsTextNode() { + isItemContainsTextNodeAndNotSingular() { const { children } = this.props; let result; React.Children.forEach(children, (element: React.ReactElement) => { @@ -80,7 +80,7 @@ export default class Item extends React.Component { result = true; } }); - return result; + return result && React.Children.count(children) > 1; } isFlexMode() { @@ -89,7 +89,7 @@ export default class Item extends React.Component { if (itemLayout === 'vertical') { return !!extra; } - return !this.isItemContainsTextNode(); + return !this.isItemContainsTextNodeAndNotSingular(); } renderItem = ({ getPrefixCls }: ConfigConsumerProps) => { diff --git a/components/list/__tests__/__snapshots__/demo.test.js.snap b/components/list/__tests__/__snapshots__/demo.test.js.snap index 6967d405a8..c9f03fcbd3 100644 --- a/components/list/__tests__/__snapshots__/demo.test.js.snap +++ b/components/list/__tests__/__snapshots__/demo.test.js.snap @@ -764,27 +764,27 @@ exports[`renders ./components/list/demo/simple.md correctly 1`] = ` class="ant-list-items" >
  • Racing car sprays burning fuel into crowd.
  • Japanese princess to wed commoner.
  • Australian walks 100km after outback crash.
  • Man charged over missing wedding girl.
  • Los Angeles battles huge wildfires.
  • @@ -824,27 +824,27 @@ exports[`renders ./components/list/demo/simple.md correctly 1`] = ` class="ant-list-items" >
  • Racing car sprays burning fuel into crowd.
  • Japanese princess to wed commoner.
  • Australian walks 100km after outback crash.
  • Man charged over missing wedding girl.
  • Los Angeles battles huge wildfires.
  • diff --git a/components/list/style/index.less b/components/list/style/index.less index 6da354048e..07ebc1c851 100644 --- a/components/list/style/index.less +++ b/components/list/style/index.less @@ -66,6 +66,7 @@ &-item { display: flex; align-items: center; + justify-content: space-between; padding: @list-item-padding; &-content {