Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Text field in form not saving before opening dialog #1158

@kkoreilly

Description

@kkoreilly

Describe the bug

If you type something in a text field in a form and then open a dialog without first exiting the text field, it will not apply the text of the text field to the struct in time for the dialog to get it. I noticed this while responding to #1108.

How to reproduce

Run the code below, type something in the text field, and then press the sign in button without first exiting the text field.

Example code

type user struct {
	Username string
}

func main() {
	b := core.NewBody()
	u := &user{}
	core.NewForm(b).SetStruct(u)
	bt := core.NewButton(b).SetText("Sign in")
	bt.OnClick(func(e events.Event) {
		makeHome(bt, u)
	})
	b.RunMainWindow()
}

func makeHome(ctx core.Widget, u *user) {
	home := core.NewBody().AddTitle("Hello, " + u.Username)
	core.NewText(home).SetText("Page content")
	home.RunFullDialog(ctx)
}

Relevant output

No response

Platform

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working correctlyconfirmedThis bug has been confirmed

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions