Skip to content

Commit

Permalink
Merge pull request react-bootstrap#1051 from react-bootstrap/propagat…
Browse files Browse the repository at this point in the history
…e-overlay-classname

[fixed] overlay classNames are maintained by overlayTrigget
  • Loading branch information
jquense committed Jul 23, 2015
2 parents eaa87c9 + 29fe417 commit ac7ada5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/Overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ class Overlay extends React.Component {
</Transition>
);
} else {
child = cloneElement(
child,
{className: classNames('in', child.className)}
);
child = cloneElement(child, {
className: classNames('in', child.props.className)
});
}

// This goes after everything else because it adds a wrapping div.
Expand Down
4 changes: 3 additions & 1 deletion src/Position.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { cloneElement } from 'react';
import classNames from 'classnames';
import domUtils from './utils/domUtils';
import { calcOverlayPosition } from './utils/overlayPositionUtils';
import CustomPropTypes from './utils/CustomPropTypes';
Expand Down Expand Up @@ -40,7 +41,7 @@ class Position extends React.Component {
}

render() {
const {children, ...props} = this.props;
const {children, className, ...props} = this.props;
const {positionLeft, positionTop, ...arrowPosition} = this.state;

const child = React.Children.only(children);
Expand All @@ -51,6 +52,7 @@ class Position extends React.Component {
...arrowPosition,
positionTop,
positionLeft,
className: classNames(className, child.props.className),
style: {
...child.props.style,
left: positionLeft,
Expand Down
13 changes: 13 additions & 0 deletions test/OverlayTriggerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ describe('OverlayTrigger', function() {
instance.state.isOverlayShown.should.be.true;
});

it('Should maintain overlay classname', function() {
const instance = ReactTestUtils.renderIntoDocument(
<OverlayTrigger trigger='click' overlay={<div className='test-overlay'>test</div>}>
<button>button</button>
</OverlayTrigger>
);

const overlayTrigger = React.findDOMNode(instance);
ReactTestUtils.Simulate.click(overlayTrigger);

expect(document.getElementsByClassName('test-overlay').length).to.equal(1)
});

it('Should pass transition callbacks to Transition', function (done) {
let count = 0;
let increment = ()=> count++;
Expand Down

0 comments on commit ac7ada5

Please sign in to comment.