Skip to content

Commit 08e316c

Browse files
committed
[*] Calendar: reset selection by esc
1 parent 5e69c04 commit 08e316c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

primitives/src/calendar.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,12 @@ impl RangeCalendarContext {
485485
self.highlighted_range.set(Some(range));
486486
}
487487
}
488+
489+
/// Set previous selected range
490+
pub fn reset_selection(&mut self, range: Option<DateRange>) {
491+
self.anchor_date.set(None);
492+
self.highlighted_range.set(range);
493+
}
488494
}
489495

490496
/// The props for the [`RangeCalendar`] component.
@@ -692,6 +698,7 @@ pub fn RangeCalendar(props: RangeCalendarProps) -> Element {
692698
set_focused_date(Some(focused_date.saturating_add(7.days())));
693699
}
694700
}
701+
Key::Escape => ctx.reset_selection((props.selected_range)()),
695702
_ => {}
696703
}
697704
},

0 commit comments

Comments
 (0)