Skip to content

Commit

Permalink
Fix bug with re-showing old content
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Jul 30, 2021
1 parent e30d3e6 commit 6b66ece
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -26,6 +26,8 @@ More detailed release notes can be found on the [releases page](https://github.c
* Tab support for focus handling missing on mobile
* ScrollToBottom not always scrolling all the way when items added to container.Scroller
* Fixed scrollbar disappearing after changing content (#2303)
* Calling SetContent a second time with the same content will not show


## 2.0.3 - 30 April 2021

Expand Down
4 changes: 4 additions & 0 deletions internal/driver/glfw/window.go
Expand Up @@ -475,6 +475,10 @@ func (w *window) SetContent(content fyne.CanvasObject) {
}

w.canvas.SetContent(content)
// show new canvas element
if content != nil {
content.Show()
}
w.RescaleContext()
}

Expand Down
14 changes: 14 additions & 0 deletions internal/driver/glfw/window_test.go
Expand Up @@ -1148,6 +1148,20 @@ func TestWindow_CloseInterception(t *testing.T) {
assert.True(t, onClosed) // Close is called if the interceptor is not set.
}

func TestWindow_SetContent_Twice(t *testing.T) {
w := createWindow("Test").(*window)

e1 := widget.NewLabel("1")
e2 := widget.NewLabel("2")

w.SetContent(e1)
assert.True(t, e1.Visible())
w.SetContent(e2)
assert.True(t, e2.Visible())
w.SetContent(e1)
assert.True(t, e1.Visible())
}

// This test makes our developer screens flash, let's not run it regularly...
//func TestWindow_Shortcut(t *testing.T) {
// w := createWindow("Test")
Expand Down

0 comments on commit 6b66ece

Please sign in to comment.