Skip to content

Abnormal Form Widget Entry Validation Behavior on Paste in Fyne 2.5.0 #5058

Closed
@zhironghsu

Description

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

In Fyne version 2.5.0, the validation function for the Entry widget within a Form widget behaves abnormally when text is pasted directly from the clipboard. The same code works as expected in version 2.4.5, where the validation is triggered correctly upon pasting text.

How to reproduce

  1. Use the provided sample code.
  2. Run the application in Fyne 2.5.0.
  3. Paste any text into the Entry widget from the clipboard.
  4. Observe that the validation function is not triggered, allowing the form to proceed with potentially invalid input.

Screenshots

I have attached two GIFs demonstrating the issue:

Fyne 2.4.5: Validation behaves normally and is triggered correctly when text is pasted into the Entry.
fyne245

Fyne 2.5.0: Validation behaves abnormally and is not triggered when text is pasted.
fyne250

Example code

package main

import (
	"errors"
	"log"

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

func main() {
	myApp := app.New()
	myWindow := myApp.NewWindow("Form Widget")

	entry := widget.NewEntry()
	entry.Validator = func(s string) error {
		if len(s) == 0 {
			return errors.New("entry cannot be empty")
		}
		return nil
	}

	form := &widget.Form{
		Items: []*widget.FormItem{ // we can specify items in the constructor
			{Text: "Entry", Widget: entry}},
		OnSubmit: func() { // optional, handle form submission
			log.Println("Form submitted:", entry.Text)
		},
	}

	myWindow.SetContent(form)
	myWindow.Resize(fyne.NewSize(300, 50))
	myWindow.ShowAndRun()
}

Fyne version

2.5.0

Go compiler version

1.20.7

Operating system and version

Windows 10 19045.4651

Additional Information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    blockerItems that would block a forthcoming releasebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions