Skip to content

Commit

Permalink
[fixed] ModalTrigger passes onFocus prop and onBlur prop to child
Browse files Browse the repository at this point in the history
  • Loading branch information
teloo committed Apr 26, 2015
1 parent 131669b commit c295a9a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ModalTrigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const ModalTrigger = React.createClass({
props.onClick = createChainedFunction(child.props.onClick, this.toggle);
props.onMouseOver = createChainedFunction(child.props.onMouseOver, this.props.onMouseOver);
props.onMouseOut = createChainedFunction(child.props.onMouseOut, this.props.onMouseOut);
props.onFocus = createChainedFunction(child.props.onFocus, this.props.onFocus);
props.onBlur = createChainedFunction(child.props.onBlur, this.props.onBlur);

return cloneElement(child, props);
}
Expand Down
30 changes: 30 additions & 0 deletions test/ModalTriggerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,34 @@ describe('ModalTrigger', function() {
ReactTestUtils.Simulate.mouseOut(modalTrigger);
assert.equal(called, true);
});

it('Should pass ModalTrigger onFocus prop to children', function() {
let called = false;
let callback = function() {
called = true;
};
let instance = ReactTestUtils.renderIntoDocument(
<ModalTrigger modal={<div>test</div>} onFocus={callback}>
<button>button</button>
</ModalTrigger>
);
let modalTrigger = instance.getDOMNode();
ReactTestUtils.Simulate.focus(modalTrigger);
assert.equal(called, true);
});

it('Should pass ModalTrigger onBlur prop to children', function() {
let called = false;
let callback = function() {
called = true;
};
let instance = ReactTestUtils.renderIntoDocument(
<ModalTrigger modal={<div>test</div>} onBlur={callback}>
<button>button</button>
</ModalTrigger>
);
let modalTrigger = instance.getDOMNode();
ReactTestUtils.Simulate.blur(modalTrigger);
assert.equal(called, true);
});
});

0 comments on commit c295a9a

Please sign in to comment.