Skip to content
Prev Previous commit
Next Next commit
Avoid incorrectly setting elementHeight
  • Loading branch information
YassienW committed Mar 13, 2020
commit 2f5f31d375a4d60d1ca341756a051928e852e3a7
10 changes: 5 additions & 5 deletions packages/react-bootstrap-table2/src/row-expand/expand-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { Transition } from 'react-transition-group';
export default class ExpandRow extends React.Component {
constructor(props) {
super(props);

this.elementHeight = 0;
}
onEnter() {
this.expandableDiv = document.getElementById(`expansion-div-${this.props.id}`);
this.elementHeight = this.expandableDiv.offsetHeight;
if (!this.elementHeight) {
this.elementHeight = this.expandableDiv.offsetHeight;
}
this.expandableDiv.style.height = '0px';
const elementHeight = this.elementHeight;
setTimeout(() => { this.expandableDiv.style.height = `${elementHeight}px`; }, 1);
Expand Down Expand Up @@ -48,13 +48,13 @@ ExpandRow.propTypes = {
expanded: PropTypes.bool,
onClosed: PropTypes.func,
className: PropTypes.string,
id: PropTypes.string
id: PropTypes.number
};

ExpandRow.defaultProps = {
children: null,
expanded: false,
onClosed: null,
className: '',
id: ''
id: null
};