fix(bui): Fix SearchField onChange prop and add onChange story
Signed-off-by: Sofia Sjöblad <ssjoblad@spotify.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/ui': patch
|
||||
---
|
||||
|
||||
Avoid overriding onChange when spreading props
|
||||
@@ -51,6 +51,7 @@ export const Default: Story = {
|
||||
style: {
|
||||
maxWidth: '300px',
|
||||
},
|
||||
'aria-label': 'Search',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -192,7 +193,7 @@ export const InHeader: Story = {
|
||||
size="small"
|
||||
variant="secondary"
|
||||
/>
|
||||
<SearchField {...args} size="small" />
|
||||
<SearchField aria-label="Search" {...args} size="small" />
|
||||
<ButtonIcon
|
||||
aria-label="Cactus icon button"
|
||||
icon={<RiCactusLine />}
|
||||
@@ -272,3 +273,24 @@ export const StartCollapsedWithButtons: Story = {
|
||||
</Flex>
|
||||
),
|
||||
};
|
||||
|
||||
export const StartCollapsedWithOnChange: Story = {
|
||||
args: {
|
||||
...StartCollapsed.args,
|
||||
},
|
||||
render: args => {
|
||||
const handleChange = (value: string) => {
|
||||
console.log('Search value:', value);
|
||||
};
|
||||
|
||||
return (
|
||||
<Flex
|
||||
direction="row"
|
||||
gap="2"
|
||||
style={{ width: '100%', maxWidth: '600px' }}
|
||||
>
|
||||
<SearchField {...args} onChange={handleChange} size="small" />
|
||||
</Flex>
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -39,6 +39,7 @@ export const SearchField = forwardRef<HTMLDivElement, SearchFieldProps>(
|
||||
secondaryLabel,
|
||||
description,
|
||||
isRequired,
|
||||
onChange,
|
||||
placeholder = 'Search',
|
||||
startCollapsed = false,
|
||||
'aria-label': ariaLabel,
|
||||
|
||||
Reference in New Issue
Block a user