From 2619cb9e062b92f42ad86deab0a051cbfb746be4 Mon Sep 17 00:00:00 2001 From: David Vogel Date: Mon, 30 Dec 2024 13:54:41 +0100 Subject: [PATCH] Change Input/TextArea ValueBinder interface fixes #1 --- .vscode/settings.json | 2 ++ components/input/text-area.go | 6 +++--- page-input.vugu | 2 +- page-input_vgen.go | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 1717350..6031593 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "cSpell.words": [ + "borderless", "Dadido", "datetime", "domrender", @@ -7,6 +8,7 @@ "ldflags", "Segoe", "simplehttp", + "Sprintf", "Typer", "vgrouter", "Vogel", diff --git a/components/input/text-area.go b/components/input/text-area.go index 9ac20dc..e12b1a6 100644 --- a/components/input/text-area.go +++ b/components/input/text-area.go @@ -9,12 +9,12 @@ import ( type TextArea struct { AttrMap vugu.AttrMap - Bind *string + Bind ValueBinder } func (c *TextArea) content() string { if c.Bind != nil { - return *c.Bind + return c.Bind.StringValue() } return "" @@ -24,6 +24,6 @@ func (c *TextArea) handleChange(event vugu.DOMEvent) { val := event.PropString("target", "value") if c.Bind != nil { - *c.Bind = val + c.Bind.SetStringValue(val) // TODO: Error is omitted, we should show it } } diff --git a/page-input.vugu b/page-input.vugu index e108c96..aa21ebb 100644 --- a/page-input.vugu +++ b/page-input.vugu @@ -122,7 +122,7 @@

Text-area

- +

 
 	
diff --git a/page-input_vgen.go b/page-input_vgen.go
index 3b0216a..14dc7fa 100644
--- a/page-input_vgen.go
+++ b/page-input_vgen.go
@@ -1272,7 +1272,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
 						vgin.BuildEnv.WireComponent(vgcomp)
 					}
 					vgin.BuildEnv.UseComponent(vgcompKey, vgcomp)	// ensure we can use this in the cache next time around
-					vgcomp.Bind = &c.textArea1
+					vgcomp.Bind = input.ValueBindAny{&c.textArea1}
 					vgcomp.AttrMap = make(map[string]interface{}, 8)
 					vgcomp.AttrMap["id"] = "page-text-area-1"
 					vgcomp.AttrMap["rows"] = "10"