From b1eb17d1d9ec2fecbb6b926b95d03827db784ae2 Mon Sep 17 00:00:00 2001 From: 07akioni <07akioni2@gmail.com> Date: Fri, 19 Nov 2021 02:49:28 +0800 Subject: [PATCH] fix(space): is shown when it has no children, closes #1605 --- CHANGELOG.en-US.md | 1 + CHANGELOG.zh-CN.md | 1 + src/space/src/Space.tsx | 1 + 3 files changed, 3 insertions(+) diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index 55ac159495b..263741ab4b4 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -18,6 +18,7 @@ ### Fixes - Fix the default value of the `suffix` internal component's `loading` property. +- Fix `n-space` is shown when it has no children, closes [#1605](https://github.com/TuSimple/naive-ui/issues/1605). ## 2.20.3 (2021-11-15) diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index 6c4a53187b5..9770ff30fc9 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -18,6 +18,7 @@ ### Fixes - 修复 `suffix` 内部组件 `loading` 属性的默认值 +- 修复 `n-space` 没有子节点的时候还被展示,关闭 [#1605](https://github.com/TuSimple/naive-ui/issues/1605). ## 2.20.3 (2021-11-15) diff --git a/src/space/src/Space.tsx b/src/space/src/Space.tsx index c99d0b860c7..a32b00af99d 100644 --- a/src/space/src/Space.tsx +++ b/src/space/src/Space.tsx @@ -98,6 +98,7 @@ export default defineComponent({ mergedClsPrefix } = this const children = flatten(getSlot(this)) + if (!children.length) return null const horizontalMargin = `${margin.horizontal}px` const semiHorizontalMargin = `${margin.horizontal / 2}px` const verticalMargin = `${margin.vertical}px`