From 6acb06bf861fae7b0abea6dee70f0f32cd83248c Mon Sep 17 00:00:00 2001 From: Akash Kava <39438041+ackava@users.noreply.github.com> Date: Mon, 30 Sep 2024 17:58:40 +0530 Subject: [PATCH] Retain default value --- src/basic/Select.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/basic/Select.tsx b/src/basic/Select.tsx index 3975601b..14709dad 100644 --- a/src/basic/Select.tsx +++ b/src/basic/Select.tsx @@ -18,8 +18,12 @@ const valueSetter = AtomControl.registerProperty("data-items", "value", (ctrl, e const refreshItems = (element: HTMLSelectElement, items?: any[]) => { items ??= element["items"]; (element as any).update = true; + const old = element.selectedIndex; + let cv = element["initialValue"]; + if (old !== -1) { + cv = element["value"]; + } element.options.length = 0; - const cv = element["initialValue"] ?? element["value"]; const lp = element["labelPath"] ?? ((item) => item?.label ?? item); const vp = element["valuePath"] ?? ((item) => item?.value ?? item); let i = 0;