Skip to content

Commit

Permalink
Merge pull request #804 from dnlkoch/fix-panel-pass-through-props
Browse files Browse the repository at this point in the history
Fix panel pass through props
  • Loading branch information
annarieger committed Aug 13, 2018
2 parents a73833f + e0f0fb0 commit 6de668d
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/Panel/Panel/Panel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Rnd from 'react-rnd';
import uniqueId from 'lodash/uniqueId.js';
import isNumber from 'lodash/isNumber.js';
import isFunction from 'lodash/isFunction.js';
import cloneDeep from 'lodash/cloneDeep.js';

import Titlebar from '../Titlebar/Titlebar.jsx';
import SimpleButton from '../../Button/SimpleButton/SimpleButton.jsx';
Expand Down Expand Up @@ -48,12 +49,6 @@ export class Panel extends React.Component {
*/
className: PropTypes.string,

/**
* The dispatch function.
@type {Function}
*/
dispatch: PropTypes.func,

/**
* The children to show in the Window.
* @type {node}
Expand Down Expand Up @@ -190,7 +185,7 @@ export class Panel extends React.Component {
tools: [],
height: 'auto',
width: 'auto',
collapseTooltip: 'collapse'
collapseTooltip: 'Collapse'
}

/**
Expand Down Expand Up @@ -323,17 +318,27 @@ export class Panel extends React.Component {
*/
render() {
const {
collapsible,
id,
className,
draggable,
children,
title,
resizeOpts,
onResize,
onResizeStart,
onResizeStop,
onEscape,
draggable,
collapsible,
closable,
height,
width,
titleBarHeight,
collapseTooltip,
closable,
onEscape,
tools,
...rndOpts
} = this.props;
let tools = [...this.props.tools];

let toolsClone = cloneDeep(tools);

const finalClassName = className
? `${className} ${this.className}`
Expand All @@ -343,11 +348,11 @@ export class Panel extends React.Component {
const enableResizing = resizeOpts === true ? undefined : resizeOpts;

if (collapsible) {
tools.unshift(<SimpleButton
toolsClone.unshift(<SimpleButton
icon="compress"
key="collapse-tool"
onClick={this.toggleCollapse.bind(this)}
tooltip={this.props.collapseTooltip}
tooltip={collapseTooltip}
size="small"
/>);
}
Expand All @@ -356,15 +361,15 @@ export class Panel extends React.Component {
'drag-handle ant-modal-header' :
'ant-modal-header';

const titleBar = this.props.title ? <Titlebar
const titleBar = title ? <Titlebar
className={titleBarClassName}
tools={tools}
tools={toolsClone}
style={{
height: this.state.titleBarHeight,
cursor: draggable ? 'move' : 'default'
}}
>
{this.props.title}
{title}
</Titlebar> : null;

return (
Expand Down Expand Up @@ -408,7 +413,7 @@ export class Panel extends React.Component {
transition: this.state.resizing ? '' : 'height 0.25s',
}}
>
{this.props.children}
{children}
</div>
</Rnd>
);
Expand Down

0 comments on commit 6de668d

Please sign in to comment.