fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
24.55k stars 1.37k forks source link

Inconsistent Validation Status Display on Entry widgets when binding/unbinding #4218

Open pbrown12303 opened 1 year ago

pbrown12303 commented 1 year ago

Checklist

Describe the bug

When an entry widget is bound with a value for the first time it displays the validation status check mark. However, if you unbind the widget and then rebind it, the validation status check mark is not displayed. In fact, it will never be displayed again with a sequence of unbinding/rebinding operations

How to reproduce

Run the attached code (it will fail the first time due to missing testdata - copy the failed results to the testdata directory and run again - it will work). Now compare afterFirstBindingTestString.xml with afterSecondBindingTestString.xml. The first binding result contains the check box, the second does not.

Screenshots

image

Example code

package widget

import (
    "testing"
    "time"

    "fyne.io/fyne/v2"
    "fyne.io/fyne/v2/data/binding"
    "fyne.io/fyne/v2/test"
    "fyne.io/fyne/v2/widget"
    "github.com/stretchr/testify/assert"
)

func TestEntryTextSize(t *testing.T) {
    str := binding.NewString()
    str.Set("TestString")
    entry := widget.NewEntry()
    entry.Resize(fyne.NewSize(200, 20))
    entry.SetText("")
    assert.Equal(t, "", entry.Text)
    time.Sleep(100 * time.Millisecond)
    test.AssertObjectRendersToMarkup(t, "beforeBinding.xml", entry)
    entry.Bind(str)
    time.Sleep(100 * time.Millisecond)
    test.AssertObjectRendersToMarkup(t, "afterFirstBindingTestString.xml", entry)
    entry.Unbind()
    entry.SetText("")
    time.Sleep(100 * time.Millisecond)
    test.AssertObjectRendersToMarkup(t, "afterFirstUnbindingTestString.xml", entry)
    entry.Bind(str)
    time.Sleep(100 * time.Millisecond)
    test.AssertObjectRendersToMarkup(t, "afterSecondBindingTestString.xml", entry)
    entry.Unbind()
    entry.SetText("")
    time.Sleep(100 * time.Millisecond)
    test.AssertObjectRendersToMarkup(t, "afterSecondUnbindingTestString.xml", entry)
}

Fyne version

2.3.5

Go compiler version

1.21.0

Operating system and version

Windows 10

Additional Information

No response

pbrown12303 commented 1 year ago

For reference, here is the whole test project. fyneEntryTextSizeTest.zip