Skip to content

Commit

Permalink
Merge pull request #7682 from Andonyaa/fix-text-input-bug
Browse files Browse the repository at this point in the history
Fixing textinput changing 'on' into 'false'
  • Loading branch information
djhi committed May 17, 2022
2 parents 55e54a9 + acafd38 commit 05edc2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/ra-core/src/form/useInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export const useInput = (props: InputProps): UseInputValue => {
if (onChange) {
onChange(...event);
}
const eventOrValue = (typeof event[0]?.target?.checked ===
'boolean' && event[0]?.target?.value === 'on'
const eventOrValue = (props.type === 'checkbox' &&
event[0]?.target?.value === 'on'
? event[0].target.checked
: event[0]?.target?.value ?? event[0]) as any;
controllerField.onChange(
Expand Down Expand Up @@ -132,6 +132,7 @@ export type InputProps<ValueType = any> = Omit<
onBlur?: (...event: any[]) => void;
onChange?: (...event: any[]) => void;
parse?: (value: any) => ValueType;
type?: string;
resource?: string;
source: string;
validate?: Validator | Validator[];
Expand Down
7 changes: 6 additions & 1 deletion packages/ra-ui-materialui/src/input/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,12 @@ export interface NumberInputProps
extends CommonInputProps,
Omit<
TextFieldProps,
'label' | 'helperText' | 'defaultValue' | 'onChange' | 'onBlur'
| 'label'
| 'helperText'
| 'defaultValue'
| 'onChange'
| 'onBlur'
| 'type'
> {
step?: string | number;
min?: string | number;
Expand Down

0 comments on commit 05edc2a

Please sign in to comment.