@@ -8,6 +8,7 @@ var FileInput = React.createClass({
8
8
parent : {
9
9
position : 'relative'
10
10
} ,
11
+ // "invisible" above the text
11
12
file : {
12
13
position : 'absolute' ,
13
14
top : 0 ,
@@ -32,6 +33,21 @@ var FileInput = React.createClass({
32
33
} ,
33
34
34
35
render : function ( ) {
36
+ // Emulated file input for when there are no children
37
+ var emulatedInput = React . DOM . input ( {
38
+ type : 'text' ,
39
+ tabIndex : - 1 ,
40
+ name : this . props . name + '_filename' ,
41
+ value : this . state . value ,
42
+ className : this . props . className ,
43
+ onChange : function ( ) { } ,
44
+ placeholder : this . props . placeholder ,
45
+ disabled : this . props . disabled ,
46
+ style : this . state . styles . text
47
+ } ) ;
48
+
49
+ var child = this . props . children ? this . props . children : emulatedInput ;
50
+
35
51
return React . DOM . div ( {
36
52
style : this . state . styles . parent
37
53
} ,
@@ -47,18 +63,7 @@ var FileInput = React.createClass({
47
63
style : this . state . styles . file
48
64
} ) ,
49
65
50
- // Emulated file input
51
- React . DOM . input ( {
52
- type : 'text' ,
53
- tabIndex : - 1 ,
54
- name : this . props . name + '_filename' ,
55
- value : this . state . value ,
56
- className : this . props . className ,
57
- onChange : function ( ) { } ,
58
- placeholder : this . props . placeholder ,
59
- disabled : this . props . disabled ,
60
- style : this . state . styles . text
61
- } ) ) ;
66
+ child ) ;
62
67
}
63
68
} ) ;
64
69
0 commit comments