From 78ebdd84056a81cc2ba11b63660e1bca57f6ce18 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Mon, 3 Oct 2022 10:31:16 -0400 Subject: [PATCH] Fix ItemObjectList to not display column toggles for columns without IDs Signed-off-by: Sebastian Malton --- .../components/item-object-list/content.tsx | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/renderer/components/item-object-list/content.tsx b/src/renderer/components/item-object-list/content.tsx index 07756760a9..f10910e8f0 100644 --- a/src/renderer/components/item-object-list/content.tsx +++ b/src/renderer/components/item-object-list/content.tsx @@ -252,7 +252,7 @@ class NonInjectedItemListLayoutContent< } renderTableHeader() { - const { customizeTableRowProps, renderTableHeader, isSelectable, isConfigurable, store } = this.props; + const { customizeTableRowProps, renderTableHeader, isSelectable, isConfigurable, store, tableId } = this.props; if (!renderTableHeader) { return null; @@ -283,7 +283,10 @@ class NonInjectedItemListLayoutContent< )) } - {isConfigurable && this.renderColumnVisibilityMenu()} + {(isConfigurable && tableId) + ? this.renderColumnVisibilityMenu(tableId) + : undefined + } ); @@ -341,8 +344,8 @@ class NonInjectedItemListLayoutContent< return !isConfigurable || !tableId || !this.props.userStore.isTableColumnHidden(tableId, columnId, showWithColumn); } - renderColumnVisibilityMenu() { - const { renderTableHeader = [], tableId } = this.props; + renderColumnVisibilityMenu(tableId: string) { + const { renderTableHeader = [] } = this.props; return ( ( - !cellProps.showWithColumn && ( - - `} - value={this.showColumn(cellProps)} - onChange={( - tableId - ? (() => cellProps.id && this.props.userStore.toggleTableColumnVisibility(tableId, cellProps.id)) - : undefined - )} - /> - - ) + .filter((props): props is TableCellProps & { id: string } => !!props.id) + .filter(props => !props.showWithColumn) + .map((cellProps) => ( + + `} + value={this.showColumn(cellProps)} + onChange={() => this.props.userStore.toggleTableColumnVisibility(tableId, cellProps.id)} + /> + )) }