This repository was archived by the owner on Jun 1, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
+
2
3
import { withStyles } from '@material-ui/core/styles' ;
4
+
3
5
import styles from './body-styles' ;
4
6
import Example from './Example' ;
5
7
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ const RadioWidget = (props: WidgetProps) => {
20
20
label,
21
21
onChange,
22
22
} = props ;
23
+
23
24
// Generating a unique field name to identify this set of radio buttons
24
25
const name = Math . random ( ) . toString ( ) ;
25
26
const { enumOptions, enumDisabled } = options ;
@@ -28,6 +29,7 @@ const RadioWidget = (props: WidgetProps) => {
28
29
// checked={checked} has been moved above name={name}, As mentioned in #349;
29
30
// this is a temporary fix for radio button rendering bug in React, facebook/react#7630.
30
31
const row = options ? options . inline : false ;
32
+
31
33
return (
32
34
< FormControl
33
35
fullWidth = { true }
Original file line number Diff line number Diff line change @@ -13,11 +13,31 @@ const TextWidget = ({
13
13
label,
14
14
value,
15
15
onChange,
16
+ onBlur,
17
+ onFocus,
16
18
autofocus,
19
+ options,
17
20
} : WidgetProps ) => {
18
21
const _onChange = ( {
19
22
target : { value } ,
20
- } : React . ChangeEvent < HTMLInputElement > ) => onChange ( value ) ;
23
+ } : React . ChangeEvent < HTMLInputElement > ) => {
24
+ let inputValue : any = value ;
25
+
26
+ if ( ! inputValue ) {
27
+ if ( options . emptyValue === undefined ) {
28
+ inputValue = undefined ;
29
+ } else {
30
+ inputValue = options . emptyValue ;
31
+ }
32
+ }
33
+
34
+ onChange ( inputValue ) ;
35
+ } ;
36
+ const _onBlur = ( { target : { value } } : React . FocusEvent < HTMLInputElement > ) =>
37
+ onBlur ( id , value ) ;
38
+ const _onFocus = ( {
39
+ target : { value } ,
40
+ } : React . FocusEvent < HTMLInputElement > ) => onFocus ( id , value ) ;
21
41
22
42
return (
23
43
< >
@@ -30,6 +50,8 @@ const TextWidget = ({
30
50
name = { name }
31
51
value = { value }
32
52
onChange = { _onChange }
53
+ onBlur = { _onBlur }
54
+ onFocus = { _onFocus }
33
55
/>
34
56
</ >
35
57
) ;
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ const TextareaWidget = ({
32
32
const _onFocus = ( {
33
33
target : { value } ,
34
34
} : React . FocusEvent < HTMLInputElement > ) => onFocus ( id , value ) ;
35
+
35
36
return (
36
37
< >
37
38
< InputLabel > { label } </ InputLabel >
You can’t perform that action at this time.
0 commit comments