Skip to content

Commit

Permalink
Editor: fix removeRow bug
Browse files Browse the repository at this point in the history
When OnDemandList is pruning rows it sometimes calls 'removeRow' on a preload
node. Editor's 'removeRow' logic assumes that the node will always be a
valid row node which causes an error when it is not. This commit adds a guard
in `Editor#removeRow` to ensure that a dgrid row object for the node exists.

Also disable the verbose logging in the Rest.html test file by default.
  • Loading branch information
msssk committed May 23, 2020
1 parent d3e89b1 commit 3d2e203
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ define([
removeRow: function (rowElement) {
var self = this;
var focusedCell = this._focusedEditorCell;
var row = this.row(rowElement);

if (focusedCell && focusedCell.row.id === this.row(rowElement).id) {
if (focusedCell && row && focusedCell.row.id === row.id) {
this._previouslyFocusedEditorCell = focusedCell;
// Pause the focusout handler until after this row has had
// time to re-render, if this removal is part of an update.
Expand Down
28 changes: 15 additions & 13 deletions test/Rest.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ <h2>A basic grid with Rest store using range headers</h2>
], function (lang, Deferred, query, List, Grid, Selection, Editor, Keyboard, Tree,
SelectServer, Rest, Trackable, Cache, TreeStore) {

var ENABLE_DEBUG_LOG = false; // set to true to enable logging preload info
var selectServer = new SelectServer({}, document.getElementById('selectServerForm'));

selectServer.startup();
Expand All @@ -80,7 +81,7 @@ <h2>A basic grid with Rest store using range headers</h2>

logPreload: function () {
var line = '';
for (var i = 0; i < 160; i++) {
for (var i = 0; i < 100; i++) {
line += '\u2500';
}
console.log(line);
Expand All @@ -107,14 +108,12 @@ <h2>A basic grid with Rest store using range headers</h2>
});
preload = preload.next;
}
console.table && console.table(preloads);
console.table && console.table(preloadNodes);
console.table(preloads);
console.table(preloadNodes);
var realRowCount = query('.dgrid-row', grid.contentNode).length;
height += 24 * realRowCount;
totalPossibleRows += realRowCount;
console.log('Height calculated from preloads = ', height);


console.log('Actual grid content height = ', gridContentHeight());
console.log('Total possible rows = ', totalPossibleRows);
console.log('Current row count = ', realRowCount);
Expand Down Expand Up @@ -158,14 +157,17 @@ <h2>A basic grid with Rest store using range headers</h2>

var refreshed = false;
var prevContentHeight = 0;
setInterval(function () {
var contentHeight = gridContentHeight();
if (refreshed || prevContentHeight != contentHeight) {
prevContentHeight = contentHeight;
refreshed = false;
grid.logPreload();
}
}, 1500);

if (ENABLE_DEBUG_LOG) {
setInterval(function () {
var contentHeight = gridContentHeight();
if (refreshed || prevContentHeight != contentHeight) {
prevContentHeight = contentHeight;
refreshed = false;
grid.logPreload();
}
}, 1500);
}

function gridContentHeight() {
var contentHeight = 0;
Expand Down

0 comments on commit 3d2e203

Please sign in to comment.