Skip to content

Commit

Permalink
Fix Admin UI not allowing negative values for float, decimal and inte…
Browse files Browse the repository at this point in the history
…ger (#5113)
  • Loading branch information
emmatown authored Mar 15, 2021
1 parent c2426c3 commit ec6f9b6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-chairs-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/fields': patch
---

Fixed Admin UI not allowing negative values for float, decimal and integer
4 changes: 2 additions & 2 deletions packages-next/fields/src/types/decimal/views/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Field = ({ field, value, onChange, autoFocus }: FieldProps<typeof c
{onChange ? (
<TextInput
autoFocus={autoFocus}
onChange={event => onChange(event.target.value.replace(/[^\d\.]/, ''))}
onChange={event => onChange(event.target.value.replace(/[^\d\.-]/, ''))}
value={value}
/>
) : (
Expand Down Expand Up @@ -60,7 +60,7 @@ export const controller = (config: Config): FieldController<string, string> => {
return (
<TextInput
onChange={event => {
props.onChange(event.target.value.replace(/[^\d\.,\s]/g, ''));
props.onChange(event.target.value.replace(/[^\d\.,\s-]/g, ''));
}}
value={props.value}
autoFocus={props.autoFocus}
Expand Down
4 changes: 2 additions & 2 deletions packages-next/fields/src/types/float/views/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Field = ({ field, value, onChange, autoFocus }: FieldProps<typeof c
{onChange ? (
<TextInput
autoFocus={autoFocus}
onChange={event => onChange(event.target.value.replace(/[^\d\.]/, ''))}
onChange={event => onChange(event.target.value.replace(/[^\d\.-]/, ''))}
value={value}
/>
) : (
Expand Down Expand Up @@ -58,7 +58,7 @@ export const controller = (config: FieldControllerConfig): FieldController<strin
return (
<TextInput
onChange={event => {
props.onChange(event.target.value.replace(/[^\d\.,\s]/g, ''));
props.onChange(event.target.value.replace(/[^\d\.,\s-]/g, ''));
}}
value={props.value}
autoFocus={props.autoFocus}
Expand Down
4 changes: 2 additions & 2 deletions packages-next/fields/src/types/integer/views/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const Field = ({ field, value, onChange, autoFocus }: FieldProps<typeof c
autoFocus={autoFocus}
type="number"
onChange={event => {
onChange(event.target.value.replace(/\D/g, ''));
onChange(event.target.value.replace(/[^\d-]/g, ''));
}}
value={value}
/>
Expand Down Expand Up @@ -62,7 +62,7 @@ export const controller = (config: FieldControllerConfig): FieldController<strin
<TextInput
type="number"
onChange={event => {
props.onChange(event.target.value.replace(/[^\d,\s]/g, ''));
props.onChange(event.target.value.replace(/[^\d,\s-]/g, ''));
}}
value={props.value}
autoFocus={props.autoFocus}
Expand Down

1 comment on commit ec6f9b6

@vercel
Copy link

@vercel vercel bot commented on ec6f9b6 Mar 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.