Forms: review r2 fixes

This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 13:02:54 -04:00
1 parent 215733e3f4
commit ab14eadcd9
21 files changed
+267 -49

No files matched your search

+33
View File
@@ -6,6 +6,7 @@ import (
"github.com/egoist/mygo/ui"
"mujicaui/icons"
"mujicaui/theme"
)
func TestInputGroupTypingAndButtons(t *testing.T) {
@@ -108,3 +109,35 @@ func TestInputGroupSnapshot(t *testing.T) {
})
})
}
// Input queued while focused must not edit a group disabled since.
func TestInputGroupDisabledAfterFocus(t *testing.T) {
value, disabled, changes := "abc", false, 0
tt := ui.NewTester(func(c *ui.Context) {
Use(c, Settings{})
ui.Column(c).Disabled(disabled).Children(func() {
if InputGroup(c, &value, InputGroupOptions{Label: "Code"}).Changed() {
changes++
}
})
}, 400, 100)
_ = tt.Click("Code")
disabled = true
tt.Type("zz")
tt.Key(0, ui.KeyBackspace)
tt.Frame()
if value != "abc" || changes != 0 {
t.Fatalf("value %q changes %d", value, changes)
}
}
func TestInputGroupHitAreasCompact(t *testing.T) {
value := ""
tt := ui.NewTester(func(c *ui.Context) {
Use(c, Settings{Density: theme.Compact})
InputGroup(c, &value, InputGroupOptions{Label: "Query", Buttons: []InputGroupButton{{Label: "Clear", Icon: icons.Must("x"), IconOnly: true}}})
}, 400, 100)
if r, ok := tt.Find("Clear"); !ok || r.W < 28 || r.H < 28 {
t.Fatalf("button %v", r)
}
}