diff --git a/src/OverlayTrigger.js b/src/OverlayTrigger.js index 8b2883aeb8..558737bb61 100644 --- a/src/OverlayTrigger.js +++ b/src/OverlayTrigger.js @@ -175,6 +175,7 @@ const OverlayTrigger = React.createClass({ render() { const trigger = React.Children.only(this.props.children); + const triggerProps = trigger.props; const props = { 'aria-describedby': this.props.overlay.props.id @@ -183,7 +184,7 @@ const OverlayTrigger = React.createClass({ // create in render otherwise owner is lost... this._overlay = this.getOverlay(); - props.onClick = createChainedFunction(trigger.props.onClick, this.props.onClick); + props.onClick = createChainedFunction(triggerProps.onClick, this.props.onClick); if (isOneOf('click', this.props.trigger)) { props.onClick = createChainedFunction(this.toggle, props.onClick); @@ -194,13 +195,13 @@ const OverlayTrigger = React.createClass({ '[react-bootstrap] Specifying only the `"hover"` trigger limits the visibilty of the overlay to just mouse users. ' + 'Consider also including the `"focus"` trigger so that touch and keyboard only users can see the overlay as well.'); - props.onMouseOver = createChainedFunction(this.handleDelayedShow, this.props.onMouseOver); - props.onMouseOut = createChainedFunction(this.handleDelayedHide, this.props.onMouseOut); + props.onMouseOver = createChainedFunction(this.handleDelayedShow, this.props.onMouseOver, triggerProps.onMouseOver); + props.onMouseOut = createChainedFunction(this.handleDelayedHide, this.props.onMouseOut, triggerProps.onMouseOut); } if (isOneOf('focus', this.props.trigger)) { - props.onFocus = createChainedFunction(this.handleDelayedShow, this.props.onFocus); - props.onBlur = createChainedFunction(this.handleDelayedHide, this.props.onBlur); + props.onFocus = createChainedFunction(this.handleDelayedShow, this.props.onFocus, triggerProps.onFocus); + props.onBlur = createChainedFunction(this.handleDelayedHide, this.props.onBlur, triggerProps.onBlur); } return cloneElement( diff --git a/test/OverlayTriggerSpec.js b/test/OverlayTriggerSpec.js index cb48067872..c50e73dc38 100644 --- a/test/OverlayTriggerSpec.js +++ b/test/OverlayTriggerSpec.js @@ -4,6 +4,8 @@ import OverlayTrigger from '../src/OverlayTrigger'; import Popover from '../src/Popover'; import Tooltip from '../src/Tooltip'; +import { render } from './helpers'; + describe('OverlayTrigger', function() { it('Should create OverlayTrigger element', function() { const instance = ReactTestUtils.renderIntoDocument( @@ -39,6 +41,21 @@ describe('OverlayTrigger', function() { instance.state.isOverlayShown.should.be.true; }); + it('Should keep trigger handlers', function(done) { + const instance = render( +
+ test
}> + + + + + , document.body); + + const overlayTrigger = React.findDOMNode(instance).firstChild; + + ReactTestUtils.Simulate.blur(overlayTrigger); + }); + it('Should maintain overlay classname', function() { const instance = ReactTestUtils.renderIntoDocument( test}> @@ -47,6 +64,7 @@ describe('OverlayTrigger', function() { ); const overlayTrigger = React.findDOMNode(instance); + ReactTestUtils.Simulate.click(overlayTrigger); expect(document.getElementsByClassName('test-overlay').length).to.equal(1);