Skip to content

Commit

Permalink
fix(create-bounty): prevent empty spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhammadUmer44 committed Sep 26, 2024
1 parent faff89a commit d43fefd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ export const CreateBounty: FC<Props> = ({ errMessage, handleClose }) => {

const isDisable = isBudgetValid(watchBudget) && !!watchNodeType

const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
if (event.key === ' ') {
event.preventDefault()
}
}

return (
<Flex>
<Flex align="center" direction="row" justify="space-between" mb={18}>
Expand All @@ -46,6 +52,7 @@ export const CreateBounty: FC<Props> = ({ errMessage, handleClose }) => {
<TextInput
id="budget"
name="budget"
onKeyDown={handleKeyDown}
placeholder="Enter budget"
rules={{
...requiredRule,
Expand Down
6 changes: 3 additions & 3 deletions src/components/ModalsContainer/CreateBountyModal/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const BUDGET_PATTERN = /^[0-9]+$/

export const isBudgetValid = (budget: string): boolean => {
const trimmedBudget = budget.trim()

return !!(trimmedBudget && /^[0-9]+$/.test(trimmedBudget))
return !!(trimmedBudget && BUDGET_PATTERN.test(trimmedBudget))
}

export const BUDGET_PATTERN = /^[0-9]+$/

0 comments on commit d43fefd

Please sign in to comment.