diff --git a/crates/ui/src/time/calendar.rs b/crates/ui/src/time/calendar.rs index 49262fc6..c1aaf202 100644 --- a/crates/ui/src/time/calendar.rs +++ b/crates/ui/src/time/calendar.rs @@ -474,6 +474,11 @@ impl CalendarState { .into() } + fn year_name(&self, offset_month: usize) -> SharedString { + let (year, _) = self.offset_year_month(offset_month); + year.to_string().into() + } + fn set_view_mode(&mut self, mode: ViewMode, _: &mut Window, cx: &mut Context) { self.view_mode = mode; cx.notify(); @@ -534,7 +539,7 @@ impl Calendar { let (_, month) = state.offset_year_month(offset_month); let day = d.day(); let is_current_month = d.month() == month; - let is_active = state.date.is_active(d) && is_current_month; + let is_active = state.date.is_active(d); let is_in_range = state.date.is_in_range(d); let date = *d; @@ -544,8 +549,10 @@ impl Calendar { .as_ref() .map_or(false, |disabled| disabled.matched(&date)); + let date_id: SharedString = format!("{}_{}", date.format("%Y-%m-%d"), offset_month).into(); + self.item_button( - d.ordinal() as usize, + date_id, day.to_string(), is_active, is_in_range, @@ -681,7 +688,7 @@ impl Calendar { _ => this.gap_3(), }) .child(state.month_name(n)) - .child(current_year.to_string()) + .child(state.year_name(n)) }), )) })