Skip to content

fix: provide asset input with onblur event handler #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/design-system/asset-input/amount-input.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface Props {
testId?: string;
className?: string;
inputClassName?: string;
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
}

export const AmountInput = ({
Expand All @@ -25,6 +26,7 @@ export const AmountInput = ({
testId,
className,
inputClassName,
onBlur,
}: Readonly<Props>): JSX.Element => {
return (
<Box className={cn(cx.amountInputSizer, className)} data-value={value}>
Expand All @@ -35,6 +37,7 @@ export const AmountInput = ({
onChange={({ target }): void => onChange?.(target.value)}
placeholder="0.0"
data-testid={testId ?? `asset-input-amount-input-${id}`}
onBlur={onBlur}
/>
</Box>
);
Expand Down
3 changes: 3 additions & 0 deletions src/design-system/asset-input/asset-input.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ interface Props {
onTickerClick?: (asset: Readonly<AssetWithFiat>) => void;
onAmountChange?: (asset: Readonly<AssetWithFiat>, amount: string) => void;
onMaxClick?: (asset: Readonly<AssetWithFiat>) => void;
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
}

export const AssetInput = ({
state,
onTickerClick,
onAmountChange,
onMaxClick,
onBlur,
}: Readonly<Props>): JSX.Element => (
<div className={cx.root}>
<Box className={cx.assetNameBox}>
Expand Down Expand Up @@ -53,6 +55,7 @@ export const AssetInput = ({
onChange={(value): void => {
onAmountChange?.(state.asset, value);
}}
onBlur={onBlur}
/>
</Box>
</Flex>
Expand Down
2 changes: 1 addition & 1 deletion src/design-system/asset-input/asset-input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default {
const AssetInputMainComponents = (): JSX.Element => (
<Variants.Row>
<Variants.Cell>
<AssetInput state={validState('1')} />
<AssetInput onBlur={() => console.log('blur')} state={validState('1')} />
</Variants.Cell>
</Variants.Row>
);
Expand Down