Skip to content

Commit 94e92a0

Browse files
AStrizhlucasmerlin
andcommitted
Fix: prevent calendar popup from closing on dropdown change (#7409)
Currently, DatePickerButton will close without saving whenever a user clicks a dropdown from year/month/date. The issue is caused because the system mistakenly interprets the user as clicking off of the calendar. This is unexpected and creates an unpleasant experience for the user. This change now allows the user to use the dropdowns as expected; it will close on save or cancel. The calendar still closes when user clicks off of it, as before. The changes here are made in: crates/egui_extras/src/datepicker/button.rs I will admit that I am not an experienced Rust developer. The changes were made with the help of ChatGPT 4.0. I have tested the changes locally, as I am using the date picker in my project. * Closes <https://github.com/emilk/egui/issues/THE_RELEVANT_ISSUE> * [x] I have followed the instructions in the PR template --------- Co-authored-by: Lucas Meurer <[email protected]>
1 parent d0bfc61 commit 94e92a0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

crates/egui_extras/src/datepicker/button.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,11 @@ impl Widget for DatePickerButton<'_> {
192192
button_response.mark_changed();
193193
}
194194

195+
// We don't want to close our popup if any other popup is open, since other popups would
196+
// most likely be the combo boxes in the date picker.
197+
let any_popup_open = ui.ctx().is_popup_open();
195198
if !button_response.clicked()
199+
&& !any_popup_open
196200
&& (ui.input(|i| i.key_pressed(Key::Escape)) || area_response.clicked_elsewhere())
197201
{
198202
button_state.picker_visible = false;

0 commit comments

Comments
 (0)