core icon indicating copy to clipboard operation
core copied to clipboard

Table: Empty headers with empty slice

Open mastercactapus opened this issue 1 year ago • 1 comments

Describe the bug

It seems table headers are blank when the passed slice has no rows.

Expected: Headers would be set based on the slice type (or have an API for setting them explicitly).

How to reproduce

Initialize an empty slice of the intended type and render a Table.

For ref, the command I ran: core run -auto-update-interval 1s web

Example code

package main

import (
	"cogentcore.org/core/core"
)

func main() {
	b := core.NewBody()

	type item struct {
		Name string
		IP   string
	}
	tbl := core.NewTable(b)
	var items []item // same behavior with items := []item{}
	tbl.SetSlice(&items)

	b.RunMainWindow()
}

Relevant output

No response

Platform

Web

mastercactapus avatar Dec 21 '24 00:12 mastercactapus

Thank you for reporting this. I can reproduce this and we will work on fixing this soon.

kkoreilly avatar Dec 21 '24 01:12 kkoreilly