File tree 2 files changed +14
-3
lines changed
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -43,8 +43,13 @@ class Tooltip extends Component {
43
43
44
44
return (
45
45
< span className = { this . props . wrapperClassName } >
46
- { cloneElement ( Children . only ( this . props . children ) , {
47
- ref : 'target' ,
46
+ { cloneElement ( child , {
47
+ ref : ( node ) => {
48
+ this . _target = node
49
+ if ( typeof child . ref === 'function' ) {
50
+ child . ref ( node )
51
+ }
52
+ } ,
48
53
...actionProps ,
49
54
} ) }
50
55
{ this . _popper ( ) }
@@ -58,7 +63,7 @@ class Tooltip extends Component {
58
63
const props = _ . omit ( this . props , 'wrapperClassName' , 'children' )
59
64
60
65
return (
61
- < PortalPopper getTargetNode = { ( ) => this . refs . target } { ...props } />
66
+ < PortalPopper getTargetNode = { ( ) => this . _target } { ...props } />
62
67
)
63
68
}
64
69
}
Original file line number Diff line number Diff line change @@ -65,6 +65,12 @@ describe('<Tooltip />', () => {
65
65
expect ( onMouseOut ) . to . be . calledWith ( ...args )
66
66
} )
67
67
68
+ it ( 'allows callee to have ref on child' , ( ) => {
69
+ const ref = sinon . spy ( )
70
+ mount ( createComponent ( { } , < div ref = { ref } /> ) )
71
+ expect ( ref ) . to . be . called
72
+ } )
73
+
68
74
describe ( 'when visible is not explicitly specified' , ( ) => {
69
75
let component
70
76
beforeEach ( ( ) => {
You can’t perform that action at this time.
0 commit comments