Skip to content

Commit

Permalink
added possibility to empty text fields
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrpospiech committed Jun 24, 2024
1 parent e1c4707 commit df3e268
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 12 deletions.
6 changes: 5 additions & 1 deletion packages/uniforms-antd/src/LongTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ function LongText({ rows = 5, ...props }: LongTextFieldProps) {
<TextArea
disabled={props.disabled}
name={props.name}
onChange={event => props.onChange(event.target.value)}
onChange={event =>
props.onChange(
event.target.value === '' ? undefined : event.target.value,
)
}
placeholder={props.placeholder}
readOnly={props.readOnly}
ref={props.inputRef}
Expand Down
6 changes: 5 additions & 1 deletion packages/uniforms-antd/src/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ function Text(props: TextFieldProps) {
<Input
disabled={props.disabled}
name={props.name}
onChange={event => props.onChange(event.target.value)}
onChange={event =>
props.onChange(
event.target.value === '' ? undefined : event.target.value,
)
}
placeholder={props.placeholder}
readOnly={props.readOnly}
ref={props.inputRef}
Expand Down
6 changes: 5 additions & 1 deletion packages/uniforms-bootstrap4/src/LongTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ function LongText(props: LongTextFieldProps) {
disabled={props.disabled}
id={props.id}
name={props.name}
onChange={event => props.onChange(event.target.value)}
onChange={event =>
props.onChange(
event.target.value === '' ? undefined : event.target.value,
)
}
placeholder={props.placeholder}
readOnly={props.readOnly}
ref={props.inputRef}
Expand Down
6 changes: 5 additions & 1 deletion packages/uniforms-bootstrap4/src/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ function Text(props: TextFieldProps) {
disabled={props.disabled}
id={props.id}
name={props.name}
onChange={event => props.onChange(event.target.value)}
onChange={event =>
props.onChange(
event.target.value === '' ? undefined : event.target.value,
)
}
placeholder={props.placeholder}
readOnly={props.readOnly}
ref={props.inputRef}
Expand Down
6 changes: 5 additions & 1 deletion packages/uniforms-bootstrap5/src/LongTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ function LongText(props: LongTextFieldProps) {
disabled={props.disabled}
id={props.id}
name={props.name}
onChange={event => props.onChange(event.target.value)}
onChange={event =>
props.onChange(
event.target.value === '' ? undefined : event.target.value,
)
}
placeholder={props.placeholder}
minLength={props.minLength}
maxLength={props.maxLength}
Expand Down
6 changes: 5 additions & 1 deletion packages/uniforms-bootstrap5/src/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ function Text(props: TextFieldProps) {
disabled={props.disabled}
id={props.id}
name={props.name}
onChange={event => props.onChange(event.target.value)}
onChange={event =>
props.onChange(
event.target.value === '' ? undefined : event.target.value,
)
}
placeholder={props.placeholder}
minLength={props.minLength}
maxLength={props.maxLength}
Expand Down
5 changes: 4 additions & 1 deletion packages/uniforms-mui/src/LongTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ const LongText = ({
margin="dense"
multiline
name={name}
onChange={event => disabled || onChange(event.target.value)}
onChange={event =>
disabled ||
onChange(event.target.value === '' ? undefined : event.target.value)
}
placeholder={placeholder}
ref={inputRef}
type={type}
Expand Down
5 changes: 4 additions & 1 deletion packages/uniforms-mui/src/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ function Text({
label={label}
margin="dense"
name={name}
onChange={event => disabled || onChange(event.target.value)}
onChange={event =>
disabled ||
onChange(event.target.value === '' ? undefined : event.target.value)
}
placeholder={placeholder}
ref={inputRef}
type={type}
Expand Down
4 changes: 3 additions & 1 deletion packages/uniforms-semantic/src/LongTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ function LongText({
disabled={disabled}
id={id}
name={name}
onChange={event => onChange(event.target.value)}
onChange={event =>
onChange(event.target.value === '' ? undefined : event.target.value)
}
placeholder={placeholder}
readOnly={readOnly}
ref={inputRef}
Expand Down
4 changes: 3 additions & 1 deletion packages/uniforms-semantic/src/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ function Text({
disabled={disabled}
id={id}
name={name}
onChange={event => onChange(event.target.value)}
onChange={event =>
onChange(event.target.value === '' ? undefined : event.target.value)
}
placeholder={placeholder}
readOnly={readOnly}
ref={inputRef}
Expand Down
4 changes: 3 additions & 1 deletion packages/uniforms-unstyled/src/LongTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ function LongText({
disabled={disabled}
id={id}
name={name}
onChange={event => onChange(event.target.value)}
onChange={event =>
onChange(event.target.value === '' ? undefined : event.target.value)
}
placeholder={placeholder}
readOnly={readOnly}
ref={inputRef}
Expand Down
4 changes: 3 additions & 1 deletion packages/uniforms-unstyled/src/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ function Text({
disabled={disabled}
id={id}
name={name}
onChange={event => onChange(event.target.value)}
onChange={event =>
onChange(event.target.value === '' ? undefined : event.target.value)
}
placeholder={placeholder}
readOnly={readOnly}
ref={inputRef}
Expand Down

0 comments on commit df3e268

Please sign in to comment.