Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2113,12 +2113,28 @@ export class KupDataTable {
result: string | KupDataColumn,
afterColumn: string
) {
this.visibleColumns = this.getVisibleColumns({
includeCodVer: true,
}).map((col) => col.name);

if (typeof result !== 'string') {
if (this.visibleColumns.findIndex((c) => c === result.name) < 0) {
// Check if dataTable has visible columns
const dataTableHasVisibleColumns =
this.visibleColumns && this.visibleColumns.length > 0;

// - If dataTableHasVisibleColumns is true:
// return every col.name without filterings
// - If dataTableHasVisibleColumns is false:
// result column is filtered out because it is already inserted in the data
// and will make resultColumnIndexNotFound false, not adding the column
this.visibleColumns = this.getVisibleColumns({
includeCodVer: true,
}).map((col) => {
if (dataTableHasVisibleColumns || col.name !== result.name) {
return col.name;
}
});

const resultColumnIndexNotFound =
this.visibleColumns.findIndex((c) => c === result.name) < 0;

if (resultColumnIndexNotFound) {
this.#kupManager.debug.logMessage(
this,
'New column [' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,9 @@ function newColumnFromMath(
...firstColumn,
name: newName,
title: title ? title : newTitle,
obj: newObj,
obj: newObj ?? { t: '', p: '', k: '' },
resultOf: formula,
visible: true,
};
dataset.columns.splice(
dataset.columns.indexOf(firstColumn) + 1,
Expand Down