Skip to content

Commit

Permalink
Merge pull request #1407 from toaster/bugfix/refresh_select
Browse files Browse the repository at this point in the history
fix Select not refreshing appropriate when using SetSelected
  • Loading branch information
toaster committed Oct 14, 2020
2 parents 2a088bd + 6a96367 commit ac86da0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions widget/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ func (s *selectRenderer) updateLabel() {
}

if s.combo.Selected == "" {
s.label.Text = s.combo.PlaceHolder
s.label.SetText(s.combo.PlaceHolder)
} else {
s.label.Text = s.combo.Selected
s.label.SetText(s.combo.Selected)
}
}
12 changes: 11 additions & 1 deletion widget/select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,24 @@ func TestSelect_SelectedIndex(t *testing.T) {
}

func TestSelect_SetSelected(t *testing.T) {
test.NewApp()
defer test.NewApp()
test.ApplyTheme(t, theme.LightTheme())

var triggered bool
var triggeredValue string
combo := widget.NewSelect([]string{"1", "2"}, func(s string) {
triggered = true
triggeredValue = s
})
combo.SetSelected("2")
w := test.NewWindow(fyne.NewContainerWithLayout(layout.NewCenterLayout(), combo))
defer w.Close()
w.Resize(fyne.NewSize(200, 150))

c := w.Canvas()
test.AssertImageMatches(t, "select/set_selected_none_selected.png", c.Capture())
combo.SetSelected("2")
test.AssertImageMatches(t, "select/set_selected_2nd_selected.png", c.Capture())
assert.Equal(t, "2", combo.Selected)
assert.True(t, triggered)
assert.Equal(t, "2", triggeredValue)
Expand Down
Binary file added widget/testdata/select/set_selected_2nd_selected.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 ac86da0

Please sign in to comment.