Skip to content

Commit 4c766a1

Browse files
Fix #2713 - search unmounts unexpectedly (#2726)
1 parent e0c217d commit 4c766a1

2 files changed

Lines changed: 35 additions & 43 deletions

File tree

src/components/search/Search.tsx

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import cx from 'classnames';
33
import Input, {COLOR, SIZE} from '../form-elements/Input';
44
import type {InputPropsType} from '../form-elements/Input';
5-
import Icon, {ICON_COLOR} from '../icons/Icon';
5+
import Icon from '../icons/Icon';
66
import Button from '../buttons/Button';
77

88
export type SearchPropsType = {
@@ -73,34 +73,21 @@ const Search = ({
7373
className={cx(`${baseClassName}__input`, inputClassName)}
7474
fullWidth
7575
/>
76-
77-
{withRoundButton ? (
78-
<div className={`${baseClassName}__icon`}>
79-
<Button
80-
variant="solid"
81-
className={cx({
82-
'sg-search-button--s': size === 's',
83-
})}
84-
icon={
85-
<Icon
86-
type="search"
87-
size={size === 'l' ? 24 : 16}
88-
color="adaptive"
89-
/>
90-
}
91-
iconOnly
92-
size={size === 'l' ? 'm' : 's'}
93-
/>
94-
</div>
95-
) : (
96-
<button className={`${baseClassName}__icon`}>
97-
<Icon
98-
type="search"
99-
color={ICON_COLOR['icon-gray-50']}
100-
size={size === 'l' ? 24 : 16}
101-
/>
102-
</button>
103-
)}
76+
<Button
77+
variant={withRoundButton ? 'solid' : 'transparent-light'}
78+
className={cx([
79+
`${baseClassName}__icon`,
80+
`${baseClassName}__icon--${size}`,
81+
{
82+
[`${baseClassName}__icon--transparent`]: !withRoundButton,
83+
},
84+
])}
85+
icon={
86+
<Icon type="search" size={size === 'l' ? 24 : 16} color="adaptive" />
87+
}
88+
iconOnly
89+
size={size === 'l' ? 'm' : 's'}
90+
/>
10491
</div>
10592
);
10693
};

src/components/search/_search.scss

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,26 @@ $includeHtml: false !default;
88
&__icon {
99
transition: color 0.3s ease-out;
1010
position: absolute;
11-
top: 0;
12-
bottom: 0;
13-
display: flex;
14-
align-items: center;
15-
justify-content: center;
16-
color: $white;
17-
background: none;
18-
border: none;
11+
top: 50%;
12+
transform: translateY(-50%);
1913
right: 5px;
20-
border-radius: 0 20px 20px 0;
14+
15+
&--s.sg-button--icon-only {
16+
height: componentSize(xs);
17+
width: componentSize(xs);
18+
}
19+
20+
&--transparent.sg-button--icon-only {
21+
width: 28px;
22+
23+
&.sg-search__icon--l {
24+
width: 36px;
25+
}
26+
27+
& .sg-button__hover-overlay {
28+
display: none;
29+
}
30+
}
2131
}
2232

2333
&__input {
@@ -43,8 +53,3 @@ $includeHtml: false !default;
4353
-webkit-appearance: none;
4454
}
4555
}
46-
47-
.sg-button.sg-button--s.sg-search-button--s {
48-
height: componentSize(xs);
49-
width: componentSize(xs);
50-
}

0 commit comments

Comments
 (0)