Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
fix(block): hide collapse icon when a control is provided in Edge (#582)
Browse files Browse the repository at this point in the history
* Issue #540: Refactor slot/content checking logic.
* Issue #540: Tidy up.
  • Loading branch information
jcfranco authored Nov 22, 2019
1 parent 69bf794 commit 6d9f0e3
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/components/calcite-block/calcite-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class CalciteBlock {
) : !disabled ? (
<slot name={SLOTS.control} />
) : null;
const hasIcon = this.el.querySelector("[slot=icon]");
const hasIcon = el.querySelector(`[slot=${SLOTS.icon}]`);
const headerContent = (
<header class={CSS.header}>
{hasIcon ? (
Expand All @@ -156,14 +156,8 @@ export class CalciteBlock {
</header>
);

let hasControl = false;
let hasContent = false;

for (let i = 0; i < el.children.length; i++) {
const isControl = el.children[i].slot === SLOTS.control;
hasControl = hasControl || isControl;
hasContent = hasContent || !isControl;
}
const controlSlot = el.querySelector(`[slot=${SLOTS.control}]`);
const hasContent = el.children.length > (controlSlot ? 1 : 0);

const headerNode = (
<div class={CSS.headerContainer}>
Expand All @@ -175,7 +169,7 @@ export class CalciteBlock {
title={toggleLabel}
>
{headerContent}
{hasControl ? null : (
{controlSlot ? null : (
<CalciteIcon
size="16"
path={open ? chevronUp16 : chevronDown16}
Expand Down

0 comments on commit 6d9f0e3

Please sign in to comment.