From f0aa8d31c8119eb321bf901c16c0fdabcc34983d Mon Sep 17 00:00:00 2001 From: Michal Pokrywka Date: Thu, 13 Nov 2025 20:47:45 +0100 Subject: [PATCH] DictSelect generates empty option only if initial value does not match any of provided options --- CHANGES.md | 6 ++++++ src/select/dict_select.rs | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 6a36cb3..57af64e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,12 @@ +## Unreleased + +### Fixed + +* `DictSelect` now generates empty option only if initial value does not match any of provided options + ## 0.1.0 - 2025-09-17 ### Added diff --git a/src/select/dict_select.rs b/src/select/dict_select.rs index adc218d..368eda7 100644 --- a/src/select/dict_select.rs +++ b/src/select/dict_select.rs @@ -33,10 +33,11 @@ pub fn DictSelect + PartialEq + ToString + 'static>( value.set(new_value.parse().unwrap_or_default()); }); + // Generate empty option only if initial value does not match any of provided options let empty = computed_tuple!(value, options).render_value_option(|(value, options)| { options .iter() - .any(|(key, _)| key != &value) + .all(|(key, _)| key != &value) .then(|| dom! {