From 77820a32b6c2250e8dd5d96e6d0719d7cba02690 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sun, 12 Nov 2023 17:28:02 +0100 Subject: [PATCH] Fix #17347 - TypeErrors in some special cases on index management One was added in #14984 Signed-off-by: William Desportes --- js/src/indexes.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/js/src/indexes.js b/js/src/indexes.js index b80605a940..debe5d014f 100644 --- a/js/src/indexes.js +++ b/js/src/indexes.js @@ -163,8 +163,10 @@ Indexes.removeColumnFromIndex = function (colIndex) { // Remove column from index array. var sourceLength = sourceArray[previousIndex[1]].columns.length; for (var i = 0; i < sourceLength; i++) { - if (sourceArray[previousIndex[1]].columns[i].col_index === colIndex) { - sourceArray[previousIndex[1]].columns.splice(i, 1); + if (i in sourceArray[previousIndex[1]].columns) { + if (sourceArray[previousIndex[1]].columns[i].col_index === colIndex) { + sourceArray[previousIndex[1]].columns.splice(i, 1); + } } } @@ -827,7 +829,11 @@ AJAX.registerOnload('indexes.js', function () { var arrayIndex = previousIndex[1]; var sourceArray = Indexes.getIndexArray(indexChoice); - if (sourceArray !== null) { + if (sourceArray === null) { + return; + } + + if (arrayIndex in sourceArray) { var sourceLength = sourceArray[arrayIndex].columns.length; var targetColumns = [];