Skip to content

Commit 7f85f26

Browse files
committed
fix(Select): popover size
1 parent 062f869 commit 7f85f26

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

src/components/fields/FilterListBox/FilterListBox.stories.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const meta: any = {
3434
controls: {
3535
exclude: baseProps,
3636
},
37+
layout: 'centered',
3738
},
3839
argTypes: {
3940
/* Content */
@@ -313,7 +314,13 @@ const herbs = [
313314
},
314315
];
315316

316-
const permissions = [
317+
interface Permission {
318+
key: string;
319+
label: string;
320+
description: string;
321+
}
322+
323+
const permissions: Permission[] = [
317324
{ key: 'read', label: 'Read', description: 'View content and data' },
318325
{ key: 'write', label: 'Write', description: 'Create and edit content' },
319326
{ key: 'delete', label: 'Delete', description: 'Remove content permanently' },
@@ -324,7 +331,7 @@ const permissions = [
324331
description: 'Review and approve content',
325332
},
326333
{ key: 'share', label: 'Share', description: 'Share content with others' },
327-
];
334+
] as const;
328335

329336
const languages = [
330337
{
@@ -400,15 +407,15 @@ export const SingleSelection: Story = {
400407

401408
export const MultipleSelection: Story = {
402409
render: (args) => (
403-
<FilterListBox {...args}>
404-
{permissions.map((permission) => (
410+
<FilterListBox<Permission> {...args} items={permissions}>
411+
{(permission) => (
405412
<FilterListBox.Item
406413
key={permission.key}
407414
description={permission.description}
408415
>
409416
{permission.label}
410417
</FilterListBox.Item>
411-
))}
418+
)}
412419
</FilterListBox>
413420
),
414421
args: {
@@ -543,15 +550,15 @@ WithHeaderAndFooter.args = {
543550

544551
export const CheckableMultipleSelection: Story = {
545552
render: (args) => (
546-
<FilterListBox {...args}>
547-
{permissions.map((permission) => (
553+
<FilterListBox {...args} items={permissions}>
554+
{(permission: (typeof permissions)[number]) => (
548555
<FilterListBox.Item
549556
key={permission.key}
550557
description={permission.description}
551558
>
552559
{permission.label}
553560
</FilterListBox.Item>
554-
))}
561+
)}
555562
</FilterListBox>
556563
),
557564
args: {
@@ -896,16 +903,17 @@ export const MultipleControlledExample: StoryFn<
896903
selectionMode="multiple"
897904
isCheckable={true}
898905
searchPlaceholder="Filter permissions..."
906+
items={permissions}
899907
onSelectionChange={(keys) => setSelectedKeys(keys as string[])}
900908
>
901-
{permissions.map((permission) => (
909+
{(permission: (typeof permissions)[number]) => (
902910
<FilterListBox.Item
903911
key={permission.key}
904912
description={permission.description}
905913
>
906914
{permission.label}
907915
</FilterListBox.Item>
908-
))}
916+
)}
909917
</FilterListBox>
910918

911919
<Text>
@@ -932,11 +940,10 @@ export const MultipleControlledExample: StoryFn<
932940
};
933941

934942
export const InForm: StoryFn = () => {
935-
const [value, setValue] = useState<string | null>(null);
936-
937943
return (
938944
<Form
939945
style={{ width: '400px' }}
946+
defaultValues={{ country: 'ca' }}
940947
onSubmit={(data) => {
941948
alert(`Form submitted with: ${JSON.stringify(data, null, 2)}`);
942949
}}
@@ -945,9 +952,7 @@ export const InForm: StoryFn = () => {
945952
isRequired
946953
name="country"
947954
label="Country"
948-
value={value}
949955
searchPlaceholder="Search countries..."
950-
onSelectionChange={(key) => setValue(key as string)}
951956
>
952957
<FilterListBox.Section title="North America">
953958
<FilterListBox.Item key="us">United States</FilterListBox.Item>

src/components/fields/Select/Select.stories.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export default {
1313
title: 'Forms/Select',
1414
component: Select,
1515
args: { width: '200px' },
16-
parameters: { controls: { exclude: baseProps } },
16+
parameters: {
17+
controls: { exclude: baseProps },
18+
layout: 'centered',
19+
},
1720
argTypes: {
1821
/* Content */
1922
selectedKey: {

src/components/fields/Select/Select.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ const OverlayElement = tasty({
133133
shadow: '0px 4px 16px #shadow',
134134
padding: '.5x',
135135
border: true,
136+
boxSizing: 'border-box',
136137

137138
transition:
138139
'transform $transition ease-out, scale $transition ease-out, theme $transition ease-out',

0 commit comments

Comments
 (0)