Skip to content

Commit d4c5025

Browse files
committed
Bandaid the ref lookups so they work work wrapped components.. bleh (react-dnd)
1 parent 743c714 commit d4c5025

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

src/object-table.jsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class ObjectTable extends React.PureComponent {
164164
}
165165
for (let rowIndex = 0; rowIndex < this.props.objects.length; rowIndex++) {
166166
let object = this.props.objects[rowIndex]
167-
let rowElem = ReactDom.findDOMNode(this.refs['object-' + object.id])
167+
let rowElem = ReactDom.findDOMNode(this.getRowFromRefs(object.id))
168168
if (!rowElem) {
169169
continue
170170
}
@@ -243,6 +243,26 @@ class ObjectTable extends React.PureComponent {
243243
return next
244244
}
245245

246+
getRowFromRefs(rowId) {
247+
// Dumb hack to clean up existing hack.
248+
let row = this.refs[`object-${rowId}`]
249+
// Unwrap
250+
while (row.decoratedComponentInstance) {
251+
row = row.decoratedComponentInstance
252+
}
253+
return row
254+
}
255+
256+
getCellFromRefs(rowId, columnKey) {
257+
// Dumb hack to clean up existing hack.
258+
let cell = this.getRowFromRefs(rowId).refs[`column-${columnKey}`]
259+
// Unwrap
260+
while (cell.decoratedComponentInstance) {
261+
cell = cell.decoratedComponentInstance
262+
}
263+
return cell
264+
}
265+
246266
getColumnFromKey(key) {
247267
const cols = this.props.columns || []
248268
return cols.find(col => col.key === key)
@@ -425,7 +445,7 @@ class ObjectTable extends React.PureComponent {
425445
}
426446
handleClickOutside(event) {
427447
if (this.state.editing) {
428-
this.refs['object-' + this.state.editing.objectId].refs['column-' + this.state.editing.columnKey].refs.editor.handleBlur()
448+
this.getCellFromRefs(this.state.editing.objectId, this.state.editing.columnKey).refs.editor.handleBlur()
429449
} else if (Object.keys(this.state.selectedRows).length !== 0 || Object.keys(this.state.selectedColumns).length !== 0) {
430450
this.setState(state => {
431451
state.selectedRows = {}

0 commit comments

Comments
 (0)