fix issue with number inputs not serializing correctly due to setting values as strings instead of numbers (#94)

consolidate number, string and checkbox value change functions

(cherry picked from commit 22c1590885db0534afabff74be7504ca9a0998b5)
This commit is contained in:
rjwats
2020-02-27 00:05:38 +00:00
committed by GitHub
parent a042633d8f
commit fb7053610f
6 changed files with 20 additions and 18 deletions

View File

@ -177,7 +177,6 @@ class ManageUsersForm extends React.Component<ManageUsersFormProps, ManageUsersF
onDoneEditing={this.doneEditingUser}
onCancelEditing={this.cancelEditingUser}
handleValueChange={this.handleUserValueChange}
handleCheckboxChange={this.handleUserCheckboxChange}
uniqueUsername={this.uniqueUsername}
/>
}

View File

@ -12,7 +12,6 @@ interface UserFormProps {
user: User;
uniqueUsername: (value: any) => boolean;
handleValueChange: (name: keyof User) => (event: React.ChangeEvent<HTMLInputElement>) => void;
handleCheckboxChange: (name: keyof User) => (event: React.ChangeEvent<HTMLInputElement>, checked: boolean) => void;
onDoneEditing: () => void;
onCancelEditing: () => void;
}
@ -30,7 +29,7 @@ class UserForm extends React.Component<UserFormProps> {
}
render() {
const { user, creating, handleValueChange, handleCheckboxChange, onDoneEditing, onCancelEditing } = this.props;
const { user, creating, handleValueChange, onDoneEditing, onCancelEditing } = this.props;
return (
<ValidatorForm onSubmit={onDoneEditing} ref={this.formRef}>
<Dialog onClose={onCancelEditing} aria-labelledby="user-form-dialog-title" open>
@ -64,7 +63,7 @@ class UserForm extends React.Component<UserFormProps> {
<Checkbox
value="admin"
checked={user.admin}
onChange={handleCheckboxChange('admin')}
onChange={handleValueChange('admin')}
/>
}
label="Admin?"