From 3d2e2031a1bf53392cba71f4448e28201993da92 Mon Sep 17 00:00:00 2001 From: Mangala SSS Khalsa Date: Fri, 22 May 2020 21:15:46 -0700 Subject: [PATCH] Editor: fix removeRow bug 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. --- Editor.js | 3 ++- test/Rest.html | 28 +++++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Editor.js b/Editor.js index fddf11cfb..e4b67bcaf 100644 --- a/Editor.js +++ b/Editor.js @@ -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. diff --git a/test/Rest.html b/test/Rest.html index 261c290ba..0bb346355 100644 --- a/test/Rest.html +++ b/test/Rest.html @@ -63,6 +63,7 @@

A basic grid with Rest store using range headers

], 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(); @@ -80,7 +81,7 @@

A basic grid with Rest store using range headers

logPreload: function () { var line = ''; - for (var i = 0; i < 160; i++) { + for (var i = 0; i < 100; i++) { line += '\u2500'; } console.log(line); @@ -107,14 +108,12 @@

A basic grid with Rest store using range headers

}); 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); @@ -158,14 +157,17 @@

A basic grid with Rest store using range headers

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;