Skip to content

Commit

Permalink
fix preview being re-enabled when changing selection
Browse files Browse the repository at this point in the history
  • Loading branch information
kotajacob committed Dec 15, 2022
1 parent a623014 commit 3ababb7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions calendar/calendar.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ func (c Calendar) Select(t time.Time) Calendar {
// SetFocus sets the focus to the months or the preview window, but will not
// enable the preview if it was hidden.
func (c *Calendar) SetFocus(f previewMode) {
if c.previewMode == previewModeHidden {
return
}

if f == previewModeFocused {
c.preview.Focus()
for id := range c.months {
Expand All @@ -191,11 +195,15 @@ func (c *Calendar) ToggleFocus() {

// TogglePreview switches the focus between the months and the preview window.
func (c *Calendar) TogglePreview() {
c.preview.Unfocus()
for id := range c.months {
c.months[id].Focus()
}
if c.previewMode == previewModeShown ||
c.previewMode == previewModeFocused {
c.SetFocus(previewModeHidden)
c.previewMode = previewModeHidden
} else {
c.SetFocus(previewModeShown)
c.previewMode = previewModeShown
}
}

Expand Down

0 comments on commit 3ababb7

Please sign in to comment.