Skip to content

Commit cf1c2e9

Browse files
authored
fix: Disable clear button instead of removing it (#1203)
* fix: Disable clear button instead of removing it * fix: Duplicate import * fix: Prettier fix
1 parent 7931379 commit cf1c2e9

4 files changed

Lines changed: 15 additions & 7 deletions

File tree

src/molecules/Select/SearchBar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,14 @@ export const SearchBar = <T extends SelectOptionRequired>({
196196
}
197197
/>
198198
)}
199-
{clearable && selectedValues.length > 0 && !loading && !disabled && (
199+
{clearable && selectedValues.length > 0 && !loading && (
200200
<ClearButton
201201
id="clear"
202202
variant="ghost_icon"
203203
onClick={handleOnClear}
204204
data-testid="clearBtn"
205205
$rightPadding={mode === 'menu'}
206+
disabled={disabled}
206207
>
207208
<Icon data={clear} size={18} />
208209
</ClearButton>

src/molecules/Select/Select.styles.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ const ClearButton = styled(Button)<ClearButtonProps>`
217217
height: 24px;
218218
left: 0;
219219
}
220+
&:disabled {
221+
svg {
222+
fill: ${colors.interactive.disabled__text.rgba};
223+
}
224+
}
220225
`;
221226

222227
interface ComboBoxChipProps {

src/molecules/Select/Select.types.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,16 @@ type CommonListSelectProps<T extends SelectOptionRequired> = {
8787
groups?: undefined;
8888
};
8989

90-
interface ListSelectWithAddItemProps<T extends SelectOptionRequired>
91-
extends CommonListSelectProps<T> {
90+
interface ListSelectWithAddItemProps<
91+
T extends SelectOptionRequired,
92+
> extends CommonListSelectProps<T> {
9293
onAddItem: (item: string) => void;
9394
itemSingularWord?: string;
9495
}
9596

96-
interface ListSelectWithoutAddItemProps<T extends SelectOptionRequired>
97-
extends CommonListSelectProps<T> {
97+
interface ListSelectWithoutAddItemProps<
98+
T extends SelectOptionRequired,
99+
> extends CommonListSelectProps<T> {
98100
onAddItem?: undefined;
99101
itemSingularWord?: undefined;
100102
}

src/molecules/Select/SingleSelect/SingleSelect.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ export const DisabledSingleSelect: Story = {
275275
await step('Verify that the select is disabled', () => {
276276
expect(canvas.getByRole('combobox')).toBeDisabled();
277277
});
278-
await step('Verify that the clear button is not rendered', () => {
279-
expect(canvas.queryByTestId('clearBtn')).not.toBeInTheDocument();
278+
await step('Verify that the clear button is disabled', () => {
279+
expect(canvas.getByTestId('clearBtn')).toBeDisabled();
280280
});
281281
},
282282
};

0 commit comments

Comments
 (0)