Skip to content

Commit 543f16b

Browse files
authored
fix: expect overflown content in several components (#629)
* fix: expect overflown content in several components * docs(CheckboxMultiSelect): add a showcase story
1 parent e1ef89d commit 543f16b

File tree

4 files changed

+138
-2
lines changed

4 files changed

+138
-2
lines changed

src/components/IconWrapper/IconWrapper.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const IconWrapper = ({
3333
<Container
3434
orientation="horizontal"
3535
gap={gap}
36+
overflow="hidden"
3637
{...props}
3738
>
3839
{icon && iconDir === "start" && (

src/components/Select/CheckboxMultiSelect.stories.tsx

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ import { useEffect, useState } from "react";
22

33
import { Meta, StoryObj } from "@storybook/react";
44

5+
import { Panel } from "../Panel/Panel";
6+
import { Text } from "../Typography/Text/Text";
7+
58
import { CheckboxMultiSelect } from "./CheckboxMultiSelect";
6-
import { selectOptions } from "./selectOptions";
9+
import { selectOptions, selectOptionsLong } from "./selectOptions";
10+
import { Spacer } from "../Spacer/Spacer";
711

812
const meta: Meta<typeof CheckboxMultiSelect> = {
913
component: CheckboxMultiSelect,
@@ -87,7 +91,7 @@ export const OptionsAsProp: StoryObj<typeof CheckboxMultiSelect> = {
8791
},
8892
};
8993

90-
export const CheckboxMultiSelectVariants = {
94+
export const CheckboxMultiSelectVariants: StoryObj<typeof CheckboxMultiSelect> = {
9195
render: () => {
9296
const [selectedCount, setSetlectedCount] = useState<number>(0);
9397

@@ -131,3 +135,109 @@ export const CheckboxMultiSelectVariants = {
131135
);
132136
},
133137
};
138+
139+
export const Showcase: StoryObj<typeof CheckboxMultiSelect> = {
140+
render: () => {
141+
return (
142+
<>
143+
<Panel
144+
hasBorder
145+
width="300px"
146+
>
147+
<Text>With overflown options</Text>
148+
<CheckboxMultiSelect options={selectOptionsLong} />
149+
</Panel>
150+
151+
<Spacer />
152+
<Panel
153+
hasBorder
154+
width="300px"
155+
>
156+
<Text>With overflown options (full width)</Text>
157+
<CheckboxMultiSelect
158+
useFullWidthItems
159+
options={selectOptionsLong}
160+
/>
161+
</Panel>
162+
163+
<Spacer />
164+
<Panel
165+
hasBorder
166+
width="300px"
167+
>
168+
<Text>Disabled</Text>
169+
<CheckboxMultiSelect
170+
disabled
171+
options={selectOptions}
172+
/>
173+
</Panel>
174+
175+
<Spacer />
176+
<Panel
177+
hasBorder
178+
width="300px"
179+
>
180+
<Text>With an error</Text>
181+
<CheckboxMultiSelect
182+
error="Incorrect value"
183+
options={selectOptions}
184+
/>
185+
</Panel>
186+
187+
<Spacer />
188+
<Panel
189+
hasBorder
190+
width="300px"
191+
>
192+
<Text>With disabled options</Text>
193+
<CheckboxMultiSelect
194+
options={[
195+
{
196+
value: "1",
197+
label: "Option 1 (disabled)",
198+
disabled: true,
199+
},
200+
{
201+
value: "2",
202+
label: "Option 2 (disabled)",
203+
disabled: true,
204+
},
205+
{
206+
value: "3",
207+
label: "Option 3",
208+
},
209+
{
210+
value: "4",
211+
label: "Option 4",
212+
},
213+
]}
214+
/>
215+
</Panel>
216+
217+
<Spacer />
218+
<Panel
219+
hasBorder
220+
width="300px"
221+
>
222+
<Text>With search</Text>
223+
<CheckboxMultiSelect
224+
showSearch
225+
options={selectOptions}
226+
/>
227+
</Panel>
228+
229+
<Spacer />
230+
<Panel
231+
hasBorder
232+
width="300px"
233+
>
234+
<Text>With custom selected text</Text>
235+
<CheckboxMultiSelect
236+
selectLabel="Something is selected"
237+
options={selectOptions}
238+
/>
239+
</Panel>
240+
</>
241+
);
242+
},
243+
};

src/components/Select/common/InternalSelect.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ export const MultiSelectCheckboxItem = forwardRef<
683683
<Container
684684
orientation="horizontal"
685685
gap="xs"
686+
overflow="hidden"
686687
>
687688
<Checkbox
688689
checked={isChecked}

src/components/Select/selectOptions.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const selectOptions: Array<SelectOptionListItem> = [
66
options: [
77
{
88
icon: "user",
9+
iconDir: "start",
910
value: "content0",
1011
label: "Content0",
1112
},
@@ -31,3 +32,26 @@ export const selectOptions: Array<SelectOptionListItem> = [
3132
label: "Content4",
3233
},
3334
];
35+
36+
export const selectOptionsLong: Array<SelectOptionListItem> = [
37+
{
38+
value: "1",
39+
label:
40+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
41+
},
42+
{
43+
value: "2",
44+
label:
45+
"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
46+
},
47+
{
48+
value: "3",
49+
label:
50+
"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.",
51+
},
52+
{
53+
value: "4",
54+
label:
55+
"Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
56+
},
57+
];

0 commit comments

Comments
 (0)