From 5555b224271d6a777a03f267e3690e777660dda4 Mon Sep 17 00:00:00 2001 From: Oliver <480930+rivo@users.noreply.github.com> Date: Sat, 30 Dec 2017 22:09:10 +0100 Subject: [PATCH] Bugfix in pages focus. --- pages.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pages.go b/pages.go index 6995a32..b2166fd 100644 --- a/pages.go +++ b/pages.go @@ -190,16 +190,19 @@ func (p *Pages) Focus(delegate func(p Primitive)) { // refocus sets the focus to the topmost visible page but only if we have focus. func (p *Pages) refocus() { - if !p.HasFocus() || p.setFocus == nil { - return - } - var topItem Primitive + var ( + topItem Primitive + hasFocus bool + ) for _, page := range p.pages { + if page.Item.GetFocusable().HasFocus() { + hasFocus = true + } if page.Visible { topItem = page.Item } } - if topItem != nil { + if hasFocus && p.setFocus != nil && topItem != nil { p.setFocus(topItem) } }