From fd51cafc1120aaaa0a4d483cd2e3f9fdd126f679 Mon Sep 17 00:00:00 2001 From: Keigo Date: Thu, 18 Dec 2025 15:16:36 +0800 Subject: [PATCH] fix(lit): correctly bind TextField type property to enable number inputs Previously, the 'type' property from A2UI JSON was not being correctly applied to the HTML input element in the Lit renderer. This was due to a property name mismatch where the component expected 'inputType' (or 'type' which conflicted with the component's own type identifier) but the root renderer was not mapping it correctly. This commit: 1. Renames the internal Lit component property to 'textFieldType' to explicitly distinguish it from the component's class type. 2. Updates the root renderer to map the JSON 'type' property to this new 'textFieldType' property. 3. Updates the restaurant finder agent example to explicitly use 'type': 'shortText' for dietary requirements, ensuring better type safety and example clarity. --- renderers/lit/src/0.8/ui/root.ts | 2 +- renderers/lit/src/0.8/ui/text-field.ts | 4 ++-- samples/agent/adk/restaurant_finder/a2ui_examples.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/renderers/lit/src/0.8/ui/root.ts b/renderers/lit/src/0.8/ui/root.ts index 3588ae10..b74a60f8 100644 --- a/renderers/lit/src/0.8/ui/root.ts +++ b/renderers/lit/src/0.8/ui/root.ts @@ -420,7 +420,7 @@ export class Root extends SignalWatcher(LitElement) { .dataContextPath=${node.dataContextPath} .label=${node.properties.label} .text=${node.properties.text} - .type=${node.properties.type} + .textFieldType=${node.properties.type} .validationRegexp=${node.properties.validationRegexp} .enableCustomElements=${this.enableCustomElements} >`; diff --git a/renderers/lit/src/0.8/ui/text-field.ts b/renderers/lit/src/0.8/ui/text-field.ts index 4d695751..fbd06237 100644 --- a/renderers/lit/src/0.8/ui/text-field.ts +++ b/renderers/lit/src/0.8/ui/text-field.ts @@ -34,7 +34,7 @@ export class TextField extends Root { accessor label: StringValue | null = null; @property() - accessor inputType: ResolvedTextField["type"] | null = null; + accessor textFieldType: ResolvedTextField["type"] | null = null; static styles = [ structuralStyles, @@ -107,7 +107,7 @@ export class TextField extends Root { id="data" .value=${value} .placeholder=${"Please enter a value"} - type=${this.inputType === "number" ? "number" : "text"} + type=${this.textFieldType === "number" ? "number" : "text"} /> `; } diff --git a/samples/agent/adk/restaurant_finder/a2ui_examples.py b/samples/agent/adk/restaurant_finder/a2ui_examples.py index b77a685e..724ddccf 100644 --- a/samples/agent/adk/restaurant_finder/a2ui_examples.py +++ b/samples/agent/adk/restaurant_finder/a2ui_examples.py @@ -132,7 +132,7 @@ {{ "id": "restaurant-address", "component": {{ "Text": {{ "text": {{ "path": "address" }} }} }} }}, {{ "id": "party-size-field", "component": {{ "TextField": {{ "label": {{ "literalString": "Party Size" }}, "text": {{ "path": "partySize" }}, "type": "number" }} }} }}, {{ "id": "datetime-field", "component": {{ "DateTimeInput": {{ "label": {{ "literalString": "Date & Time" }}, "value": {{ "path": "reservationTime" }}, "enableDate": true, "enableTime": true }} }} }}, - {{ "id": "dietary-field", "component": {{ "TextField": {{ "label": {{ "literalString": "Dietary Requirements" }}, "text": {{ "path": "dietary" }} }} }} }}, + {{ "id": "dietary-field", "component": {{ "TextField": {{ "label": {{ "literalString": "Dietary Requirements" }}, "text": {{ "path": "dietary" }}, "type": "shortText" }} }} }}, {{ "id": "submit-button", "component": {{ "Button": {{ "child": "submit-reservation-text", "action": {{ "name": "submit_booking", "context": [ {{ "key": "restaurantName", "value": {{ "path": "restaurantName" }} }}, {{ "key": "partySize", "value": {{ "path": "partySize" }} }}, {{ "key": "reservationTime", "value": {{ "path": "reservationTime" }} }}, {{ "key": "dietary", "value": {{ "path": "dietary" }} }}, {{ "key": "imageUrl", "value": {{ "path": "imageUrl" }} }} ] }} }} }} }}, {{ "id": "submit-reservation-text", "component": {{ "Text": {{ "text": {{ "literalString": "Submit Reservation" }} }} }} }} ]