Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Popover inside of of Popover #57

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/mix.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
placeholder
23 changes: 23 additions & 0 deletions examples/mix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Tooltip from 'rc-tooltip';
const Popover = Tooltip;
import 'rc-tooltip/assets/bootstrap.less';

const panel = (<select>
<option value="lucy"> lucy </option>
<option value="eric"> eric </option>
<option value="yiminghe"> yiminghe </option>
</select>);

const content = (
<Popover overlay={panel} trigger="click">
<button type="primary">Hover me</button>
</Popover>
);

ReactDOM.render(
<Popover overlay={content} title="Title">
<button type="primary">Hover me</button>
</Popover>
, document.getElementById('__react-content'));
10 changes: 9 additions & 1 deletion src/Tooltip.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const Tooltip = React.createClass({
{arrowContent}
</div>,
<div className={`${prefixCls}-inner`} key="content">
{typeof overlay === 'function' ? overlay() : overlay}
{this.renderOverlay(overlay)}
</div>,
]);
},
Expand All @@ -57,6 +57,14 @@ const Tooltip = React.createClass({
return this.refs.trigger.getPopupDomNode();
},

renderOverlay(overlay) {
const overlayElement = typeof overlay === 'function' ? overlay() : overlay;
if (overlayElement.type.displayName === 'Tooltip') {
return React.cloneElement(overlayElement, { getPopupContainer: this.getPopupDomNode });
}
return overlayElement;
},

render() {
const {
overlayClassName, trigger,
Expand Down