Skip to content

Commit 7033a1b

Browse files
qili26nstepien
qili26
authored andcommitted
fix: drag jumps to the right due to the failed merge (adazzle#1564)
1 parent d240f74 commit 7033a1b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/react-data-grid/src/HeaderCell.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default class HeaderCell extends React.Component {
3333

3434
state = { resizing: false };
3535

36-
headerCellRef = (node) => this.headerCell = node;
36+
headerCell = React.createRef();
3737

3838
onDragStart = (e) => {
3939
this.setState({ resizing: true });
@@ -59,7 +59,7 @@ export default class HeaderCell extends React.Component {
5959

6060
getWidthFromMouseEvent = (e) => {
6161
const right = e.pageX || (e.touches && e.touches[0] && e.touches[0].pageX) || (e.changedTouches && e.changedTouches[e.changedTouches.length - 1].pageX);
62-
const left = ReactDOM.findDOMNode(this).getBoundingClientRect().left;
62+
const left = this.headerCell.current ? this.headerCell.current.getBoundingClientRect().left : 0;
6363
return right - left;
6464
};
6565

@@ -120,7 +120,7 @@ export default class HeaderCell extends React.Component {
120120
'react-grid-HeaderCell--frozen': isFrozen(column)
121121
}, this.props.className, column.cellClass);
122122
const cell = (
123-
<div ref={this.headerCellRef} className={className} style={this.getStyle()}>
123+
<div ref={this.headerCell} className={className} style={this.getStyle()}>
124124
{this.getCell()}
125125
{resizeHandle}
126126
</div>

0 commit comments

Comments
 (0)