Skip to content

Commit

Permalink
Call callback if dismissed in simple case too
Browse files Browse the repository at this point in the history
  • Loading branch information
ole108 committed Nov 5, 2024
1 parent 3d75849 commit f26945b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
3 changes: 3 additions & 0 deletions dialog/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ func (p *ColorPickerDialog) updateUI() {
p.dialog.create(container.NewGridWithColumns(2, p.dialog.dismiss, confirm))
} else {
p.dialog.content = container.NewVBox(p.createSimplePickers()...)
p.dialog.dismiss.OnTapped = func() {
p.callback(nil)
}
p.dialog.create(container.NewGridWithColumns(1, p.dialog.dismiss))
}
}
Expand Down
30 changes: 27 additions & 3 deletions dialog/color_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,50 @@ func TestColorDialog_SetColor(t *testing.T) {

func TestColorDialog_Buttons(t *testing.T) {
for name, tt := range map[string]struct {
action func(d *ColorPickerDialog, w fyne.Window)
action func(d *ColorPickerDialog, w fyne.Window)
advanced bool
expectedCalled bool
expectedColored bool
}{
"confirm": {
"confirmAdvanced": {
action: func(d *ColorPickerDialog, w fyne.Window) {
test.FocusNext(w.Canvas()) // advanced accordion
test.FocusNext(w.Canvas()) // dismiss button
test.FocusNext(w.Canvas()) // confirm button
w.Canvas().Focused().TypedKey(&fyne.KeyEvent{Name: fyne.KeySpace})
},
advanced: true,
expectedCalled: true,
expectedColored: true,
},
"dismiss": {
"dismissAdvanced": {
action: func(d *ColorPickerDialog, w fyne.Window) {
test.FocusNext(w.Canvas()) // advanced accordion
test.FocusNext(w.Canvas()) // dismiss button
w.Canvas().Focused().TypedKey(&fyne.KeyEvent{Name: fyne.KeySpace})
},
advanced: true,
expectedCalled: true,
expectedColored: false,
},
"confirmSimple": {
action: func(d *ColorPickerDialog, w fyne.Window) {
test.FocusNext(w.Canvas()) // advanced accordion
test.FocusNext(w.Canvas()) // dismiss button
test.FocusNext(w.Canvas()) // confirm button
w.Canvas().Focused().TypedKey(&fyne.KeyEvent{Name: fyne.KeySpace})
},
advanced: false,
expectedCalled: true,
expectedColored: true,
},
"dismissSimple": {
action: func(d *ColorPickerDialog, w fyne.Window) {
test.FocusNext(w.Canvas()) // advanced accordion
test.FocusNext(w.Canvas()) // dismiss button
w.Canvas().Focused().TypedKey(&fyne.KeyEvent{Name: fyne.KeySpace})
},
advanced: false,
expectedCalled: true,
expectedColored: false,
},
Expand Down

0 comments on commit f26945b

Please sign in to comment.