Skip to content

Commit 3aba859

Browse files
authored
💄 Align search and clear icon in Filter search field to vertical center (#1185)
1 parent 4f082b5 commit 3aba859

2 files changed

Lines changed: 43 additions & 34 deletions

File tree

src/organisms/Filter/Filter.styles.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ export const Section = styled.section`
5252
}
5353
min-height: calc(48px - (2 * ${spacings.medium_small}));
5454
align-items: center;
55-
flex-grow: 1;
5655
display: flex;
57-
flex-wrap: wrap;
56+
flex-grow: 1;
5857
gap: ${spacings.x_small};
5958
padding: ${spacings.medium_small} ${spacings.small};
6059
cursor: text;
@@ -78,6 +77,13 @@ export const Section = styled.section`
7877
}
7978
`;
8079

80+
export const SearchAndValuesWrapper = styled.span`
81+
display: flex;
82+
flex-wrap: wrap;
83+
flex-grow: 1;
84+
gap: ${spacings.x_small};
85+
`;
86+
8187
export const SearchField = styled.input`
8288
background: transparent;
8389
width: 0;

src/organisms/Filter/Filter.tsx

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import {
1313
Container,
1414
Content,
15+
SearchAndValuesWrapper,
1516
SearchField,
1617
SearchFieldWrapper,
1718
Section,
@@ -133,39 +134,41 @@ export function Filter<T extends string>({
133134
data={search_icon}
134135
color={colors.text.static_icons__tertiary.rgba}
135136
/>
136-
{(Object.keys(values) as Array<T>).flatMap((key) =>
137-
values[key].map(({ label, icon }, index, list) => (
138-
<StyledChip
139-
key={`${label}-${index}-${key}`}
140-
onDelete={() => onClearFilter(key, index)}
141-
leadingIconData={icon}
142-
$tryingToRemove={
143-
attemptingToRemove === key && index === list.length - 1
144-
}
145-
>
146-
{label}
147-
</StyledChip>
148-
))
149-
)}
150-
<SearchFieldWrapper>
151-
{'autoCompleteOptions' in rest && rest.autoCompleteOptions && (
152-
<AutoCompleteText
153-
search={search}
154-
autoCompleteOptions={rest.autoCompleteOptions}
155-
/>
137+
<SearchAndValuesWrapper>
138+
{(Object.keys(values) as Array<T>).flatMap((key) =>
139+
values[key].map(({ label, icon }, index, list) => (
140+
<StyledChip
141+
key={`${label}-${index}-${key}`}
142+
onDelete={() => onClearFilter(key, index)}
143+
leadingIconData={icon}
144+
$tryingToRemove={
145+
attemptingToRemove === key && index === list.length - 1
146+
}
147+
>
148+
{label}
149+
</StyledChip>
150+
))
156151
)}
157-
<SearchField
158-
ref={searchRef}
159-
id={`filter-search-${id}`}
160-
type="search"
161-
autoComplete="off"
162-
value={search}
163-
placeholder={hasAnyValues ? undefined : placeholder}
164-
onChange={onSearchChange}
165-
onKeyDownCapture={handleOnKeyDown}
166-
onFocus={handleOnFocus}
167-
/>
168-
</SearchFieldWrapper>
152+
<SearchFieldWrapper>
153+
{'autoCompleteOptions' in rest && rest.autoCompleteOptions && (
154+
<AutoCompleteText
155+
search={search}
156+
autoCompleteOptions={rest.autoCompleteOptions}
157+
/>
158+
)}
159+
<SearchField
160+
ref={searchRef}
161+
id={`filter-search-${id}`}
162+
type="search"
163+
autoComplete="off"
164+
value={search}
165+
placeholder={hasAnyValues ? undefined : placeholder}
166+
onChange={onSearchChange}
167+
onKeyDownCapture={handleOnKeyDown}
168+
onFocus={handleOnFocus}
169+
/>
170+
</SearchFieldWrapper>
171+
</SearchAndValuesWrapper>
169172
{(Object.values(values) as SelectOptionRequired[][]).some(
170173
(list) => list.length > 0
171174
) && (

0 commit comments

Comments
 (0)