From 71e44442ee5bbd419b1105590ebd1f711b365d11 Mon Sep 17 00:00:00 2001 From: Matthew Oliveira Date: Wed, 18 Jan 2023 17:09:25 -0500 Subject: [PATCH] fix(carousel): ignore visually hidden modal headers to fix extra space --- .../expressive-modal/expressive-modal.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/web-components/src/components/expressive-modal/expressive-modal.ts b/packages/web-components/src/components/expressive-modal/expressive-modal.ts index 4134d1cf6b8..0d1eb4885b8 100644 --- a/packages/web-components/src/components/expressive-modal/expressive-modal.ts +++ b/packages/web-components/src/components/expressive-modal/expressive-modal.ts @@ -1,7 +1,7 @@ /** * @license * - * Copyright IBM Corp. 2020, 2022 + * Copyright IBM Corp. 2020, 2023 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. @@ -333,9 +333,19 @@ class DDSExpressiveModal extends StableSelectorMixin( const { name } = target as HTMLSlotElement; const hasContent = (target as HTMLSlotElement) .assignedNodes() - .some( - (node) => node.nodeType !== Node.TEXT_NODE || node!.textContent!.trim() - ); + .some((node) => { + // Allow non-empty text nodes. + if (node.nodeType === Node.TEXT_NODE && node!.textContent!.trim()) { + return true; + } + // Allow only element nodes that don't have a .bx--visually-hidden + // class. + if (node instanceof Element) { + return !node.classList.contains('bx--visually-hidden'); + } + // No opinion on other cases. + return true; + }); this[slotExistencePropertyNames[name] || '_hasBody'] = hasContent; }