From 8f419db87138a828dc9078ca05d4b8fb623bf17c Mon Sep 17 00:00:00 2001 From: "kai.arrowood" Date: Mon, 15 Apr 2024 12:51:28 -0400 Subject: [PATCH 1/3] fix(ktable): column visibility menu button --- src/components/KTable/KTable.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/KTable/KTable.vue b/src/components/KTable/KTable.vue index 094f88530c..75708d0e15 100644 --- a/src/components/KTable/KTable.vue +++ b/src/components/KTable/KTable.vue @@ -578,7 +578,11 @@ const resizingColumn = ref('') const resizerHoveredColumn = ref('') // lowest priority - currently hovered resizable column (mouse is somewhere in the ) const currentHoveredColumn = ref('') -const hasColumnVisibilityMenu = computed((): boolean => tableHeaders.value.filter((header: TableHeader) => header.hidable).length > 0) +const hasColumnVisibilityMenu = computed((): boolean => { + // has hidable columns, no error/loading/empty state + return tableHeaders.value.filter((header: TableHeader) => header.hidable).length > 0 && + !props.hasError && !isTableLoading.value && !props.isLoading && (data.value && data.value.length) +}) // columns whose visibility can be toggled const visibilityColumns = computed((): TableHeader[] => tableHeaders.value.filter((header: TableHeader) => header.hidable)) // visibility preferences from the host app (initialized by app) From 3c3217811386844f6d5ffed5bb0dae95c40b1041 Mon Sep 17 00:00:00 2001 From: "kai.arrowood" Date: Mon, 15 Apr 2024 12:57:37 -0400 Subject: [PATCH 2/3] fix(*): ts --- src/components/KTable/KTable.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/KTable/KTable.vue b/src/components/KTable/KTable.vue index 75708d0e15..80eb2b78fa 100644 --- a/src/components/KTable/KTable.vue +++ b/src/components/KTable/KTable.vue @@ -580,8 +580,8 @@ const resizerHoveredColumn = ref('') const currentHoveredColumn = ref('') const hasColumnVisibilityMenu = computed((): boolean => { // has hidable columns, no error/loading/empty state - return tableHeaders.value.filter((header: TableHeader) => header.hidable).length > 0 && - !props.hasError && !isTableLoading.value && !props.isLoading && (data.value && data.value.length) + return !!(tableHeaders.value.filter((header: TableHeader) => header.hidable).length > 0 && + !props.hasError && !isTableLoading.value && !props.isLoading && (data.value && data.value.length)) }) // columns whose visibility can be toggled const visibilityColumns = computed((): TableHeader[] => tableHeaders.value.filter((header: TableHeader) => header.hidable)) From e8040927e6f63c7b8c284423e3fa08cbc2c03874 Mon Sep 17 00:00:00 2001 From: "kai.arrowood" Date: Mon, 15 Apr 2024 13:36:55 -0400 Subject: [PATCH 3/3] fix(*): init columnwidths --- src/components/KTable/KTable.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/KTable/KTable.vue b/src/components/KTable/KTable.vue index 80eb2b78fa..9880a1a6c0 100644 --- a/src/components/KTable/KTable.vue +++ b/src/components/KTable/KTable.vue @@ -711,7 +711,7 @@ const tdlisteners = computed((): any => { } }) -const columnWidths = ref>({}) +const columnWidths = ref>(props.tablePreferences.columnWidths || {}) const columnStyles = computed(() => { const styles: Record = {} for (const colKey in columnWidths.value) {