Skip to content

Commit

Permalink
fix(ktable): column visibility menu button (#2136)
Browse files Browse the repository at this point in the history
Hide column visibility menu when loading/error/empty state and persist initial column widths from table preferences.
  • Loading branch information
kaiarrowood authored Apr 15, 2024
1 parent 58d75fc commit e1a6854
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/KTable/KTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,11 @@ const resizingColumn = ref('')
const resizerHoveredColumn = ref('')
// lowest priority - currently hovered resizable column (mouse is somewhere in the <th>)
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)
Expand Down Expand Up @@ -707,7 +711,7 @@ const tdlisteners = computed((): any => {
}
})
const columnWidths = ref<Record<string, number>>({})
const columnWidths = ref<Record<string, number>>(props.tablePreferences.columnWidths || {})
const columnStyles = computed(() => {
const styles: Record<string, any> = {}
for (const colKey in columnWidths.value) {
Expand Down

0 comments on commit e1a6854

Please sign in to comment.