Skip to content

Commit cb79b69

Browse files
authored
Merge pull request #126 from input-output-hk/fix/lw-12854-provide-on-blur-handler-for-asset-input
fix: provide asset input with onblur event handler
2 parents 8cd97bc + 69459f5 commit cb79b69

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/design-system/asset-input/amount-input.component.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface Props {
1515
testId?: string;
1616
className?: string;
1717
inputClassName?: string;
18+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
1819
}
1920

2021
export const AmountInput = ({
@@ -25,6 +26,7 @@ export const AmountInput = ({
2526
testId,
2627
className,
2728
inputClassName,
29+
onBlur,
2830
}: Readonly<Props>): JSX.Element => {
2931
return (
3032
<Box className={cn(cx.amountInputSizer, className)} data-value={value}>
@@ -35,6 +37,7 @@ export const AmountInput = ({
3537
onChange={({ target }): void => onChange?.(target.value)}
3638
placeholder="0.0"
3739
data-testid={testId ?? `asset-input-amount-input-${id}`}
40+
onBlur={onBlur}
3841
/>
3942
</Box>
4043
);

src/design-system/asset-input/asset-input.component.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ interface Props {
1616
onTickerClick?: (asset: Readonly<AssetWithFiat>) => void;
1717
onAmountChange?: (asset: Readonly<AssetWithFiat>, amount: string) => void;
1818
onMaxClick?: (asset: Readonly<AssetWithFiat>) => void;
19+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
1920
}
2021

2122
export const AssetInput = ({
2223
state,
2324
onTickerClick,
2425
onAmountChange,
2526
onMaxClick,
27+
onBlur,
2628
}: Readonly<Props>): JSX.Element => (
2729
<div className={cx.root}>
2830
<Box className={cx.assetNameBox}>
@@ -53,6 +55,7 @@ export const AssetInput = ({
5355
onChange={(value): void => {
5456
onAmountChange?.(state.asset, value);
5557
}}
58+
onBlur={onBlur}
5659
/>
5760
</Box>
5861
</Flex>

src/design-system/asset-input/asset-input.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default {
3333
const AssetInputMainComponents = (): JSX.Element => (
3434
<Variants.Row>
3535
<Variants.Cell>
36-
<AssetInput state={validState('1')} />
36+
<AssetInput onBlur={() => console.log('blur')} state={validState('1')} />
3737
</Variants.Cell>
3838
</Variants.Row>
3939
);

0 commit comments

Comments
 (0)