File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 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 {
4343
4444 return (
4545 < 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+ } ,
4853 ...actionProps ,
4954 } ) }
5055 { this . _popper ( ) }
@@ -58,7 +63,7 @@ class Tooltip extends Component {
5863 const props = _ . omit ( this . props , 'wrapperClassName' , 'children' )
5964
6065 return (
61- < PortalPopper getTargetNode = { ( ) => this . refs . target } { ...props } />
66+ < PortalPopper getTargetNode = { ( ) => this . _target } { ...props } />
6267 )
6368 }
6469}
Original file line number Diff line number Diff line change @@ -65,6 +65,12 @@ describe('<Tooltip />', () => {
6565 expect ( onMouseOut ) . to . be . calledWith ( ...args )
6666 } )
6767
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+
6874 describe ( 'when visible is not explicitly specified' , ( ) => {
6975 let component
7076 beforeEach ( ( ) => {
You can’t perform that action at this time.
0 commit comments