Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
- Free a removed `EdgeBar` view and a removed scroll view a bar was over, instead of the lists of bars and of the scroll views they reach into keeping them past their new end, and through each the whole subtree it was in, while another bar stays (#1023 by @iFwu).
- Land a `List`'s scroll to a row, or to its end, where it asks when rows were inserted, removed or measured above the viewport in the same update, instead of shifted by the scroll that would have kept the visible rows in place (#1019 by @iFwu).
- Pull a scroll view's offset back to its end in `nsgotest` when its content shrinks or its viewport grows past it, and report where it went, as macOS, Windows, Linux, Android and the web do, instead of leaving it past the end (#1020 by @iFwu).
- Free a removed `Overlay`, `Modal`, `Position: Fixed` view or `Tooltip` bubble instead of the view hosting it keeping it, and through it the whole subtree it was in, for the life of the window, so rebuilding a view with a tooltip no longer grows memory (#1006 by @iFwu).

## [0.2.0] - 2026-11-19

Expand Down
27 changes: 27 additions & 0 deletions core/tooltip_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package core

import (
"fmt"
goruntime "runtime"
"testing"
"weak"

"github.com/nsgo-dev/nsgo/internal/driver"
)
Expand Down Expand Up @@ -128,3 +131,27 @@ func TestHiddenTooltipDoesNotFollowScrolls(t *testing.T) {
t.Fatal("a shown tooltip does not follow a scroll")
}
}

// A view rebuilt with its tooltip leaves nothing of the old one behind: the root view hosts only the shown copy's overlay, and the old view and what was in it are freed.
func TestRebuiltTooltipFreesTheOldView(t *testing.T) {
var rev *Signal[int]
h := newHost(t, Size{Width: 300, Height: 300}, func(cx *Scope) Node {
rev = NewSignal(cx, 0)
return Dynamic(func(*Scope) Node {
return View{TestID: fmt.Sprint("trigger", rev.Get()), Label: "Save", Role: RoleButton, Tooltip: Text{Content: "Writes the document"}}
})
})
h.commit()
old := weak.Make(h.find("trigger0"))
for i := 1; i <= 3; i++ {
rev.Set(i)
h.commit()
}
if n := len(h.tree.view.hosted); n != 1 {
t.Fatalf("the root view hosts %d overlays, want the shown tooltip's 1", n)
}
goruntime.GC()
if old.Value() != nil {
t.Fatal("the view rebuilt away stays in memory")
}
}
Loading