Skip to content

Commit

Permalink
fix(carousel): ignore visually hidden modal headers to fix extra space
Browse files Browse the repository at this point in the history
  • Loading branch information
m4olivei committed Jan 18, 2023
1 parent 621afcf commit 71e4444
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 71e4444

Please sign in to comment.