-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Description
Its kind of hard to explain, but here is an example of the issue
package main
import (
"fmt"
"github.com/roblillack/spot"
"github.com/roblillack/spot/ui"
"time"
)
func main() {
ui.Init()
spot.BuildFn(func(ctx *spot.RenderContext) spot.Component {
toggle, setToggle := spot.UseState[bool](ctx, true)
components := []spot.Component{
&ui.Button{
Width: 200,
Height: 20,
Title: "toggle",
OnClick: func() {
setToggle(!toggle)
},
},
}
if toggle {
components = append(components, &ui.ListBox{
Y: 20,
Width: 200,
Height: 180,
Values: []string{"Item 1", "Item 2"},
Selection: []int{0},
OnSelect: func(ints []int) {
fmt.Printf("Selected %v at %v\n", ints[0], time.Now().Unix())
},
})
}
return &ui.Window{
Title: "Issue #22",
Width: 200,
Height: 200,
Children: components,
}
}).Mount()
ui.Run()
}When the program starts, it works fine, but when you press toggle, then press toggle again, the rows are all blank, and the OnSelect callback is broken, even though the values are being passed through the exact same way.
This is a problem because if you want to have a multi-page app it breaks functionality for the ListBox, other components seem to function as expected when doing the same type of test