From 44dcc878fe8f407cafb1c127df9acf24833cf3c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madis=20N=C3=B5mme?= Date: Mon, 13 Jan 2025 07:03:04 -0600 Subject: [PATCH] Correctly show default-value c-select-input when missing on 1st render --- ui/src/ethlance/ui/component/select_input.cljs | 6 ++++-- ui/src/ethlance/ui/page/sign_up.cljs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/src/ethlance/ui/component/select_input.cljs b/ui/src/ethlance/ui/component/select_input.cljs index 2b438b32..cb93afa6 100644 --- a/ui/src/ethlance/ui/component/select_input.cljs +++ b/ui/src/ethlance/ui/component/select_input.cljs @@ -67,6 +67,7 @@ "Component has both controlled `selection` and uncontrolled `default-selection` attributes set.") (let [value-fn (or value-fn identity) label-fn (or label-fn identity) + current-selection (if (contains? opts :default-selection) @*current-default-selection selection) opts (dissoc opts :label :selections :on-select :default-selection @@ -75,8 +76,9 @@ :default-search-text :size :value-fn - :label-fn) - current-selection (if (contains? opts :default-selection) @*current-default-selection selection)] + :label-fn)] + (when (nil? @*current-default-selection) + (reset! *current-default-selection (or default-selection selection))) [:div.ethlance-select-input (merge {:class [color-class size-class]} opts) [:div.main {:title (or (label-fn current-selection) label) diff --git a/ui/src/ethlance/ui/page/sign_up.cljs b/ui/src/ethlance/ui/page/sign_up.cljs index fb814bba..f5b35340 100644 --- a/ui/src/ethlance/ui/page/sign_up.cljs +++ b/ui/src/ethlance/ui/page/sign_up.cljs @@ -154,7 +154,7 @@ :error? (not (:candidate/rate form-validation)) :on-change #(>evt [:page.sign-up/set-candidate-rate (js/parseInt %)])}]] [c-user-country-input - {:form-values form-values}]] + {:form-values (select-keys form-values [:user/country])}]] [:div.second-forms [c-user-languages-input {:form-values form-values}]