From d532ff66a19cbd7bb2afe589db23c58123c36057 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 14:14:09 +0000 Subject: [PATCH] The slide takes the keyboard back when nothing has it and Tab has work --- crates/ui-egui/src/app/document_focus.rs | 12 +++++++----- crates/ui-egui/src/document_focus_tests.rs | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/app/document_focus.rs b/crates/ui-egui/src/app/document_focus.rs index 380e00ac0..fee5c624b 100644 --- a/crates/ui-egui/src/app/document_focus.rs +++ b/crates/ui-egui/src/app/document_focus.rs @@ -79,8 +79,9 @@ impl SlideApp { /// Ends the document window's pass, after the views; `before` is the presentation the last pass drew. The pass's /// input has changed what Tab has to do, so the document is declared again. A presentation that opened or became - /// active asks for the focus, and so does the document when a dialog, menu or popup closes and leaves nothing - /// focused. Both wait for the last of them to close. + /// active asks for the focus. So does the document with nothing focused, when a dialog, menu or popup has closed, and + /// while Tab has work on the slide (a ribbon field committed with Enter leaves nothing focused). All wait for the + /// last dialog, menu or popup to close. pub(super) fn finish_document(&mut self, ctx: &egui::Context, before: Option) { let drawn = self.document_focus.drawn; if drawn.is_none() { @@ -88,7 +89,8 @@ impl SlideApp { self.document_focus.uncovered = 0; return; } - host_canvas(ctx, self.document_keeps_tab(ctx)); + let keeps_tab = self.document_keeps_tab(ctx); + host_canvas(ctx, keeps_tab); if drawn != before { self.document_focus.opened = ASKING_PASSES; } @@ -96,11 +98,11 @@ impl SlideApp { self.document_focus.uncovered = ASKING_PASSES; return; } + let unfocused = ctx.memory(|m| m.focused().is_none()); let DocumentFocus { opened, uncovered, .. } = &mut self.document_focus; - if *opened == 0 && *uncovered == 0 { + if *opened == 0 && *uncovered == 0 && !(unfocused && keeps_tab) { return; } - let unfocused = ctx.memory(|m| m.focused().is_none()); if unfocused || (*opened > 0 && Self::focus_is_free(ctx)) { (*opened, *uncovered) = (0, 0); focus_document(ctx); diff --git a/crates/ui-egui/src/document_focus_tests.rs b/crates/ui-egui/src/document_focus_tests.rs index 78ffa2824..f857a376f 100644 --- a/crates/ui-egui/src/document_focus_tests.rs +++ b/crates/ui-egui/src/document_focus_tests.rs @@ -98,6 +98,23 @@ fn after_a_dialog_closes_tab_selects_the_next_object() { assert_eq!((selected(&h), focused(&h)), (vec![first], Some(document_id()))); } +#[test] +fn after_enter_in_a_ribbon_field_tab_selects_the_next_object() { + let mut h = harness(); + h.state_mut().ui.tab = "Transitions".into(); + tab(&mut h); + let objects: Vec<_> = h.state().session.active().unwrap().shapes().iter().map(|s| s.id).collect(); + assert_eq!(selected(&h), objects[..1]); + h.get_by_role_and_label(Role::TextInput, "Duration value").focus(); + h.run_steps(2); + assert!(h.ctx.text_edit_focused()); + press(&mut h, Modifiers::NONE, Key::Enter); + assert!(!h.ctx.text_edit_focused(), "Enter commits the field"); + assert!(h.state().session.active().unwrap().selection.text.is_none(), "and reaches nothing on the slide"); + tab(&mut h); + assert_eq!((selected(&h), focused(&h)), (vec![objects[1]], Some(document_id()))); +} + #[test] fn a_press_in_the_sorter_takes_the_keyboard_from_a_focused_button() { let mut h = harness();