Skip to content

Commit

Permalink
Merge pull request #2178 from AnkushJadhav/fix/2028
Browse files Browse the repository at this point in the history
Fix Form does not render HintTexts for more than one item
  • Loading branch information
andydotxyz committed Apr 19, 2021
2 parents f07ef8e + 55ccd8c commit 7c9f320
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion widget/form.go
Expand Up @@ -69,7 +69,7 @@ func (f *Form) AppendItem(item *FormItem) {
f.Items = append(f.Items, item)
if f.itemGrid != nil {
f.itemGrid.Add(f.createLabel(item.Text))
f.itemGrid.Add(item.Widget)
f.itemGrid.Add(f.createInput(item))
f.setUpValidation(item.Widget, len(f.Items)-1)
}

Expand Down
27 changes: 27 additions & 0 deletions widget/form_test.go
Expand Up @@ -300,3 +300,30 @@ func TestForm_Disable_Validation(t *testing.T) {

test.AssertImageMatches(t, "form/disable_validation_disabled_valid.png", w.Canvas().Capture())
}

func TestForm_HintsRendered(t *testing.T) {
app := test.NewApp()
defer test.NewApp()
app.Settings().SetTheme(theme.LightTheme())

f := NewForm()

fi1 := NewFormItem("Form Item 1", NewEntry())
fi1.HintText = "HT1"
f.AppendItem(fi1)

fi2 := NewFormItem("Form Item 2", NewEntry())
fi2.HintText = "HT2"

f.AppendItem(fi2)

fi3 := NewFormItem("Form Item 3", NewEntry())
fi3.HintText = "HT3"

f.AppendItem(fi3)

w := test.NewWindow(f)
defer w.Close()

test.AssertImageMatches(t, "form/hints_rendered.png", w.Canvas().Capture())
}
Binary file added widget/testdata/form/hints_rendered.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7c9f320

Please sign in to comment.