diff --git a/src/View/ViewContainer.vala b/src/View/ViewContainer.vala index 034cf5f87..fe2966de8 100644 --- a/src/View/ViewContainer.vala +++ b/src/View/ViewContainer.vala @@ -461,6 +461,7 @@ namespace Files.View { public void set_active_state (bool is_active, bool animate = true) { var aslot = get_current_slot (); if (aslot != null) { + aslot.grab_focus (); /* Since async loading it may not have been determined whether slot is loadable */ aslot.set_active_state (is_active, animate); if (is_active) { diff --git a/src/View/Window.vala b/src/View/Window.vala index fe2b43db6..af6c8bb8f 100644 --- a/src/View/Window.vala +++ b/src/View/Window.vala @@ -336,18 +336,19 @@ public class Files.View.Window : Hdy.ApplicationWindow { }; key_controller.key_pressed.connect ((keyval, keycode, state) => { - if (!current_container.has_focus) { - return Gdk.EVENT_PROPAGATE; - } - - var mods = state & Gtk.accelerator_get_default_mod_mask (); - /* Use find function instead of view interactive search */ - if (mods == 0 || mods == Gdk.ModifierType.SHIFT_MASK) { - /* Use printable characters to initiate search */ - var uc = (unichar)(Gdk.keyval_to_unicode (keyval)); - if (uc.isprint ()) { - activate_action ("find", uc.to_string ()); - return Gdk.EVENT_STOP; + var focus_widget = get_focus (); + if (focus_widget != null && current_container != null && + focus_widget.is_ancestor (current_container)) { + + var mods = state & Gtk.accelerator_get_default_mod_mask (); + /* Use find function instead of view interactive search */ + if (mods == 0 || mods == Gdk.ModifierType.SHIFT_MASK) { + /* Use printable characters to initiate search */ + var uc = (unichar)(Gdk.keyval_to_unicode (keyval)); + if (uc.isprint ()) { + activate_action ("find", uc.to_string ()); + return Gdk.EVENT_STOP; + } } }