WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit b0d2f47

Browse files
committed
[*] DatePicker: some updates
1 parent 015725f commit b0d2f47

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

primitives/src/date_picker.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -879,13 +879,10 @@ fn DateElement(props: DateElementProps) -> Element {
879879
.ok()
880880
.filter(|date| ctx.enabled_date_range.contains(*date))
881881
{
882-
let new_date = if ctx.available_ranges.read().valid_interval(date) {
883-
Some(date)
884-
} else {
885-
None
886-
};
887882
tracing::info!("Parsed date: {date:?}");
888-
props.on_date_change.call(new_date);
883+
if ctx.available_ranges.read().valid_interval(date) {
884+
props.on_date_change.call(Some(date));
885+
};
889886
}
890887
}
891888
});
@@ -1095,8 +1092,12 @@ pub fn DateRangePickerInput(props: DatePickerInputProps) -> Element {
10951092

10961093
use_effect(move || {
10971094
if let (Some(start), Some(end)) = (start_date(), end_date()) {
1098-
let range = Some(DateRange::new(start, end));
1095+
// force auto validation for input range
1096+
if end < start {
1097+
return;
1098+
}
10991099

1100+
let range = Some(DateRange::new(start, end));
11001101
ctx.set_range(range);
11011102
};
11021103
});

0 commit comments

Comments
 (0)