(core) Fix JS error when pasting data with merged cells.

Summary:
Pasting data with merged cells from Excel (or from HTML tables with colspan/rowspan),
we used to get "Cannot read property 'displayValue' of undefined".

Fix it by assuming that some cell values may be empty.

Test Plan: Added test case reproduces the failure without the fix, and passes with.

Reviewers: alexmojaki

Reviewed By: alexmojaki

Differential Revision: https://phab.getgrist.com/D2990
pull/12/head
Dmitry S 3 years ago
parent 00c1a0c688
commit 572b59cc0c

@ -369,9 +369,9 @@ BaseView.prototype._parsePasteForView = function(data, cols) {
_.isObject(data[0][0]) && data[0][0].hasOwnProperty('displayValue')) {
richData = data.map((col, idx) => {
if (col[0].colType === updateColTypes[idx]) {
return col.map(v => v.hasOwnProperty('rawValue') ? v.rawValue : v.displayValue);
return col.map(v => v && v.hasOwnProperty('rawValue') ? v.rawValue : v.displayValue);
} else {
return col.map(v => v.displayValue);
return col.map(v => v && v.displayValue);
}
});
}

Loading…
Cancel
Save