From 0a4c4db50426238bec6b40482c1ca9131708b659 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sun, 12 Nov 2023 17:14:14 +0100 Subject: [PATCH] Fix #17381, Fix #17347 - TypeError when removing indexes on columns Signed-off-by: William Desportes --- js/src/indexes.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/js/src/indexes.js b/js/src/indexes.js index c9229750a0..8c29999dc7 100644 --- a/js/src/indexes.js +++ b/js/src/indexes.js @@ -159,17 +159,19 @@ Indexes.removeColumnFromIndex = function (colIndex) { return; } - // 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 (previousIndex[1] in sourceArray) { + // 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); + } } - } - // Remove index completely if no columns left. - if (sourceArray[previousIndex[1]].columns.length === 0) { - sourceArray.splice(previousIndex[1], 1); + // Remove index completely if no columns left. + if (sourceArray[previousIndex[1]].columns.length === 0) { + sourceArray.splice(previousIndex[1], 1); + } } // Update current index details.