From 97b096201aa7bb433f740f88e59f8a638474bc9a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 25 Jun 2026 00:08:40 -0400 Subject: [PATCH] fix(ssr): map defaultValue/defaultChecked to controlled value in SSR (v3.5.2) An uncontrolled form field set via defaultValue (or defaultChecked) serialized the prop literally (), which the browser ignores, so the field rendered empty/unchecked server-side. normalizeFormValueProps now maps defaultValue -> value and defaultChecked -> checked (only when the controlled prop is absent, so an explicit value wins), applied at the top of both host renderers. Running before the controlled-value logic, the mapping flows through every form element: gets a value attribute, `, + }, + { + "select-defaultValue-selects-option", + html.Select(html.Props{Raw: map[string]any{"defaultValue": "b"}}, + html.Option(html.Props{Value: "a"}, ui.Text("A")), + html.Option(html.Props{Value: "b"}, ui.Text("B"))), + ``, + }, + { + "no-default-unchanged", + html.Input(html.Props{Type: "text", Value: "v"}), + ``, + }, + } + for _, parseCase := range cases { + out, err := ui.RenderToString(parseCase.node) + if err != nil { + t.Fatalf("%s: render error: %v", parseCase.name, err) + } + if out != parseCase.want { + t.Errorf("%s:\n got %q\nwant %q", parseCase.name, out, parseCase.want) + } + } +}