From f184997f06dbaa0c8e505c5c395dd4aa67b822dc Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Fri, 26 Jul 2024 13:25:35 -0700 Subject: [PATCH 1/2] exclude icons from list (was already in table) and use consistent expression to exclude --- core/list.go | 2 +- core/table.go | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/core/list.go b/core/list.go index 39958522a7..c280ec8e6c 100644 --- a/core/list.go +++ b/core/list.go @@ -486,7 +486,7 @@ func (lb *ListBase) BindSelect(val *int) *ListBase { func (lb *ListBase) UpdateMaxWidths() { lb.maxWidth = 0 npv := reflectx.NonPointerValue(lb.elementValue) - isString := npv.Type().Kind() == reflect.String + isString := npv.Type().Kind() == reflect.String && npv.Type() != reflect.TypeOf((*icons.Icon)(nil)).Elem() if !isString || lb.SliceSize == 0 { return } diff --git a/core/table.go b/core/table.go index 6303c26ab4..22bf3028d7 100644 --- a/core/table.go +++ b/core/table.go @@ -197,9 +197,8 @@ func (tb *Table) UpdateMaxWidths() { tb.colMaxWidths[fli] = 0 val := tb.sliceElementValue(0) fval := val.FieldByIndex(field.Index) - _, isicon := fval.Interface().(icons.Icon) - isString := fval.Type().Kind() == reflect.String - if !isString || isicon { + isString := fval.Type().Kind() == reflect.String && fval.Type() != reflect.TypeOf((*icons.Icon)(nil)).Elem() + if !isString { continue } mxw := 0 From 1b0a083ee24e4cc93895765fcf2bdd2146135403 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Fri, 26 Jul 2024 14:25:33 -0700 Subject: [PATCH 2/2] use reflect.TypeFor -- much nicer --- core/list.go | 2 +- core/table.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/list.go b/core/list.go index c280ec8e6c..c7bb2b244f 100644 --- a/core/list.go +++ b/core/list.go @@ -486,7 +486,7 @@ func (lb *ListBase) BindSelect(val *int) *ListBase { func (lb *ListBase) UpdateMaxWidths() { lb.maxWidth = 0 npv := reflectx.NonPointerValue(lb.elementValue) - isString := npv.Type().Kind() == reflect.String && npv.Type() != reflect.TypeOf((*icons.Icon)(nil)).Elem() + isString := npv.Type().Kind() == reflect.String && npv.Type() != reflect.TypeFor[icons.Icon]() if !isString || lb.SliceSize == 0 { return } diff --git a/core/table.go b/core/table.go index 22bf3028d7..a53a1a87f4 100644 --- a/core/table.go +++ b/core/table.go @@ -197,7 +197,7 @@ func (tb *Table) UpdateMaxWidths() { tb.colMaxWidths[fli] = 0 val := tb.sliceElementValue(0) fval := val.FieldByIndex(field.Index) - isString := fval.Type().Kind() == reflect.String && fval.Type() != reflect.TypeOf((*icons.Icon)(nil)).Elem() + isString := fval.Type().Kind() == reflect.String && fval.Type() != reflect.TypeFor[icons.Icon]() if !isString { continue }