Skip to content

Commit fda0c3a

Browse files
committed
fix: ensure AlertBox display messages only when present
1 parent 9ec9dfd commit fda0c3a

File tree

1 file changed

+40
-38
lines changed

1 file changed

+40
-38
lines changed

packages/ui/src/AlertBox/AlertBox.tsx

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,45 +33,47 @@ const AlertBox = ({ className, alertType, children, title, limitHeight, handleBt
3333
}, [children, limitHeight])
3434

3535
return (
36-
<Wrapper className={className} alertType={alertType} enabledHeightToggle={enabledHeightToggle}>
37-
{title ? (
38-
<>
39-
<Header>
40-
{IconComp} {title}{' '}
41-
</Header>
42-
{showFullHeight ? children : cutAlert}
43-
</>
44-
) : (
45-
<ContentWrapper
46-
data-tag="content"
47-
grid
48-
gridTemplateColumns={handleBtnClose !== undefined ? 'auto 1fr auto' : 'auto 1fr'}
49-
gridColumnGap={1}
50-
flexAlignItems={'flex-start'}
51-
{...props}
52-
>
53-
{IconComp}
54-
<Content flex showFullHeight={showFullHeight} limitHeight={limitHeight} ref={alertContentRef}>
36+
(title || children) && (
37+
<Wrapper className={className} alertType={alertType} enabledHeightToggle={enabledHeightToggle}>
38+
{title ? (
39+
<>
40+
<Header>
41+
{IconComp} {title}{' '}
42+
</Header>
5543
{showFullHeight ? children : cutAlert}
56-
</Content>
57-
{handleBtnClose !== undefined && (
58-
<IconButton size="small" onClick={handleBtnClose}>
59-
<Icon name="Close" size={24} />
60-
</IconButton>
61-
)}
62-
</ContentWrapper>
63-
)}
64-
{limitHeight && enabledHeightToggle && (
65-
<AdjustHeightWrapper>
66-
<ButtonContainer>
67-
<AdjustHeightButton onClick={() => setShowFullHeight(!showFullHeight)}>
68-
{showFullHeight ? 'Minimize' : 'Expand'}
69-
{showFullHeight ? <Icon name="ChevronUp" size={16} /> : <Icon name="ChevronDown" size={16} />}
70-
</AdjustHeightButton>
71-
</ButtonContainer>
72-
</AdjustHeightWrapper>
73-
)}
74-
</Wrapper>
44+
</>
45+
) : (
46+
<ContentWrapper
47+
data-tag="content"
48+
grid
49+
gridTemplateColumns={handleBtnClose !== undefined ? 'auto 1fr auto' : 'auto 1fr'}
50+
gridColumnGap={1}
51+
flexAlignItems={'flex-start'}
52+
{...props}
53+
>
54+
{IconComp}
55+
<Content flex showFullHeight={showFullHeight} limitHeight={limitHeight} ref={alertContentRef}>
56+
{showFullHeight ? children : cutAlert}
57+
</Content>
58+
{handleBtnClose !== undefined && (
59+
<IconButton size="small" onClick={handleBtnClose}>
60+
<Icon name="Close" size={24} />
61+
</IconButton>
62+
)}
63+
</ContentWrapper>
64+
)}
65+
{limitHeight && enabledHeightToggle && (
66+
<AdjustHeightWrapper>
67+
<ButtonContainer>
68+
<AdjustHeightButton onClick={() => setShowFullHeight(!showFullHeight)}>
69+
{showFullHeight ? 'Minimize' : 'Expand'}
70+
{showFullHeight ? <Icon name="ChevronUp" size={16} /> : <Icon name="ChevronDown" size={16} />}
71+
</AdjustHeightButton>
72+
</ButtonContainer>
73+
</AdjustHeightWrapper>
74+
)}
75+
</Wrapper>
76+
)
7577
)
7678
}
7779

0 commit comments

Comments
 (0)