keymap ui: Fix keymap editor search bugs (#34579)

Keystroke input now gets cleared when toggling to normal search mode
Main search bar is focused when toggling to normal search mode

This also gets rid of highlight on focus from keystroke_editor because
it also matched the search bool field and was redundant

Release Notes:

- N/A
This commit is contained in:
Anthony Eid 2025-07-16 18:05:26 -04:00 committed by Joseph T. Lyons
parent 484e39dcba
commit f249ee481d

View file

@ -304,7 +304,7 @@ impl KeymapEditor {
let keystroke_editor = cx.new(|cx| {
let mut keystroke_editor = KeystrokeInput::new(None, window, cx);
keystroke_editor.highlight_on_focus = false;
keystroke_editor.search = true;
keystroke_editor
});
@ -1036,18 +1036,16 @@ impl KeymapEditor {
self.search_mode = self.search_mode.invert();
self.on_query_changed(cx);
// Update the keystroke editor to turn the `search` bool on
self.keystroke_editor.update(cx, |keystroke_editor, cx| {
keystroke_editor
.set_search_mode(matches!(self.search_mode, SearchMode::KeyStroke { .. }));
cx.notify();
});
match self.search_mode {
SearchMode::KeyStroke { .. } => {
window.focus(&self.keystroke_editor.read(cx).recording_focus_handle(cx));
}
SearchMode::Normal => {}
SearchMode::Normal => {
self.keystroke_editor.update(cx, |editor, cx| {
editor.clear_keystrokes(&ClearKeystrokes, window, cx)
});
window.focus(&self.filter_editor.focus_handle(cx));
}
}
}
@ -2419,7 +2417,6 @@ enum KeyPress<'a> {
struct KeystrokeInput {
keystrokes: Vec<Keystroke>,
placeholder_keystrokes: Option<Vec<Keystroke>>,
highlight_on_focus: bool,
outer_focus_handle: FocusHandle,
inner_focus_handle: FocusHandle,
intercept_subscription: Option<Subscription>,
@ -2447,7 +2444,6 @@ impl KeystrokeInput {
Self {
keystrokes: Vec::new(),
placeholder_keystrokes,
highlight_on_focus: true,
inner_focus_handle,
outer_focus_handle,
intercept_subscription: None,
@ -2666,10 +2662,6 @@ impl KeystrokeInput {
self.inner_focus_handle.clone()
}
fn set_search_mode(&mut self, search: bool) {
self.search = search;
}
fn start_recording(&mut self, _: &StartRecording, window: &mut Window, cx: &mut Context<Self>) {
if !self.outer_focus_handle.is_focused(window) {
return;
@ -2829,7 +2821,7 @@ impl Render for KeystrokeInput {
.track_focus(&self.inner_focus_handle)
.on_modifiers_changed(cx.listener(Self::on_modifiers_changed))
.size_full()
.when(self.highlight_on_focus, |this| {
.when(!self.search, |this| {
this.focus(|mut style| {
style.border_color = Some(colors.border_focused);
style