From d23bd8eec14e786287b311caa53b5ab830112756 Mon Sep 17 00:00:00 2001 From: Breno Calazans Date: Wed, 27 Jan 2021 18:35:27 -0300 Subject: [PATCH] Use props children in slots if their slot children prop is empty --- CHANGELOG.md | 3 +++ react/utils/slots.tsx | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a869e7dce..068291752 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed +- Use props `children` in slots if slot children is empty. + ## [8.126.10] - 2021-01-26 ### Fixed diff --git a/react/utils/slots.tsx b/react/utils/slots.tsx index 2b2285133..d4c228e85 100644 --- a/react/utils/slots.tsx +++ b/react/utils/slots.tsx @@ -52,7 +52,11 @@ export function generateSlot({ runtime={runtime} hydration={hydration} > - {slotChildren} + {Array.isArray(slotChildren) && + slotChildren.length === 0 && + componentLoaderPropsWithContent.children + ? componentLoaderPropsWithContent.children + : slotChildren} ) }