Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra row dividers rendered on using SetColumnWidth to update a table post initial render #2266

Closed
AnkushJadhav opened this issue May 27, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@AnkushJadhav
Copy link
Contributor

AnkushJadhav commented May 27, 2021

Describe the bug:

When SetColumnWidth is called on a table after it has been initially rendered, a few extra row dividers are rendered.
On playing around with the amount of underlying data that was being updated, I noticed that this issue generally occurs when the underlying data set has a large number of columns (upwards of 10 columns as per my tests).
I also noticed a trend as such:

  • Less than 10 columns did not reproduce the issue
  • ~10-15 columns caused the extra lines to be rendered, but the lines gradually disappeared on scrolling the table or resizing the window
  • Greater than 15 columns caused the lines to be persistent, and they did not disappear even on scrolling or resizing

To Reproduce:

Steps to reproduce the behaviour:

  1. Run the example code provided below
  2. Notice the extra row dividers being rendered of the lower half of the window

Screenshots:

fyne-table-render-issue

Example code:

import (
	"fmt"
	"time"

	"fyne.io/fyne/v2"
	fyneApp "fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/widget"
)

const (
	appID    = "com.github.ankushjadhav.dynamoist"
	appTitle = "Dynamoist"
)


func getColWidths(data [][]string) []float32 {
	res := make([]float32, 0)
	for _, row := range data {
		for i, col := range row {
			cur := float32(len(fmt.Sprint(col)) * 10)
			if len(res) <= i {
				res = append(res, cur)
			} else {
				if res[i] <= cur {
					res[i] = cur
				}
			}
		}
	}
	return res
}

func main() {
	gui := fyneApp.NewWithID(appID)
	w := gui.NewWindow(appTitle)

	data := make([][]string, 0)

	t := widget.NewTable(func() (int, int) {
		if len(data) > 0 {
			return len(data), len(data[0])
		}
		return 0, 0
	}, func() fyne.CanvasObject {
		return widget.NewLabel("")
	}, func(tci widget.TableCellID, co fyne.CanvasObject) {
		co.(*widget.Label).SetText(data[tci.Row][tci.Col])
	})

	w.SetContent(t)

	go func() {
		time.Sleep(2 * time.Second)
		for i := 0; i < 200; i++ {
			row := make([]string, 0)
			for j := 0; j < 20; j++ {
				row = append(row, fmt.Sprintf("                       "))
			}
			data = append(data, row)
		}
		wi := getColWidths(data)
		for i, v := range wi {
			if v > 200 {
				v = 200
			}
			t.SetColumnWidth(i, v)
		}
		t.Refresh()
	}()

	w.Resize(fyne.Size{700, 700})
	w.CenterOnScreen()
	w.ShowAndRun()
}

Device (please complete the following information):

  • OS: MacOS Big Sur
  • Version: 11.1
  • Go version: 1.16.3
  • Fyne version: 2.0.2
@AnkushJadhav AnkushJadhav added the unverified A bug that has been reported but not verified label May 27, 2021
@andydotxyz andydotxyz added bug Something isn't working and removed unverified A bug that has been reported but not verified labels Jun 1, 2021
@andydotxyz
Copy link
Member

The fix is on develop branch and also the release/v2.0.x for upcoming v2.0.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants