fix(bui): Fix SearchField onChange prop and add onChange story

Signed-off-by: Sofia Sjöblad <ssjoblad@spotify.com>
This commit is contained in:
Sofia Sjöblad
2025-09-23 14:26:18 +02:00
parent bc889c66c4
commit 4adbb03a27
3 changed files with 29 additions and 1 deletions
+5
View File
@@ -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,