Skip to content
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

fix: pressing enter doesn't set max #1168

Merged
merged 3 commits into from
Nov 16, 2022
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
14 changes: 9 additions & 5 deletions src/components/common/InputValueHelper/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import type { ReactNode, SyntheticEvent } from 'react'
import { Link } from '@mui/material'
import { InputAdornment, Link } from '@mui/material'
import type { InputAdornmentProps } from '@mui/material'

type InputValueHelperProps = {
children: ReactNode
onClick: () => void
disabled?: boolean
position?: InputAdornmentProps['position']
}

const InputValueHelper = ({ children, onClick, disabled = false }: InputValueHelperProps) => {
const InputValueHelper = ({ children, onClick, disabled = false, position = 'end' }: InputValueHelperProps) => {
const handleClick = (e: SyntheticEvent) => {
e.preventDefault()
onClick()
}

return (
<Link component="button" onClick={handleClick} sx={disabled ? { visibility: 'hidden' } : undefined}>
{children}
</Link>
<InputAdornment position={position}>
<Link type="button" component="button" onClick={handleClick} sx={disabled ? { visibility: 'hidden' } : undefined}>
{children}
</Link>
</InputAdornment>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ const SendAssetsForm = ({ onSubmit, formData }: SendAssetsFormProps): ReactEleme
? Math.min(+spendingLimit.amount, +selectedToken.balance).toString()
: selectedToken.balance

setValue(SendAssetsField.amount, safeFormatUnits(amount, selectedToken.tokenInfo.decimals))
setValue(SendAssetsField.amount, safeFormatUnits(amount, selectedToken.tokenInfo.decimals), {
shouldValidate: true,
})
}

return (
Expand Down