From 4092e81ada231a6dbe0d0f5324a83816c30069d9 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Mon, 17 Nov 2025 10:59:46 -0300 Subject: [PATCH] keymap_editor: Adjust some items of the UI (#42876) - Only showing the "Create" menu item in the right-click context menu for actions that _do not_ contain a binding already assigned to them - Only show the "Clear Input" icon button in the keystroke modal when the input is focused/in recording mode - Add a subtle hover style to the table rows just to make it easier to navigate Release Notes: - N/A --- crates/keymap_editor/src/keymap_editor.rs | 4 ++- .../src/ui_components/keystroke_input.rs | 30 +++++++++++-------- crates/ui/src/components/data_table.rs | 5 ++-- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/crates/keymap_editor/src/keymap_editor.rs b/crates/keymap_editor/src/keymap_editor.rs index b5b9f92a491b1f8f5b3f68828095b5a7b6cecb39..58a2a5d044f208d967b58e275a5e908ff0c63418 100644 --- a/crates/keymap_editor/src/keymap_editor.rs +++ b/crates/keymap_editor/src/keymap_editor.rs @@ -958,12 +958,14 @@ impl KeymapEditor { let context_menu = ContextMenu::build(window, cx, |menu, _window, _cx| { menu.context(self.focus_handle.clone()) + .when(selected_binding_is_unbound, |this| { + this.action("Create", Box::new(CreateBinding)) + }) .action_disabled_when( selected_binding_is_unbound, "Edit", Box::new(EditBinding), ) - .action("Create", Box::new(CreateBinding)) .action_disabled_when( selected_binding_is_unbound, "Delete", diff --git a/crates/keymap_editor/src/ui_components/keystroke_input.rs b/crates/keymap_editor/src/ui_components/keystroke_input.rs index 5f85e5124f84dc6fc9a9f3ab95e72f15dc5fefeb..f1f583be7a6bb0aa1796c7c03d9aea084b3bdd3b 100644 --- a/crates/keymap_editor/src/ui_components/keystroke_input.rs +++ b/crates/keymap_editor/src/ui_components/keystroke_input.rs @@ -636,18 +636,24 @@ impl Render for KeystrokeInput { ) } }) - .child( - IconButton::new("clear-btn", IconName::Backspace) - .shape(IconButtonShape::Square) - .tooltip(Tooltip::for_action_title( - "Clear Keystrokes", - &ClearKeystrokes, - )) - .when(!is_focused, |this| this.icon_color(Color::Muted)) - .on_click(cx.listener(|this, _event, window, cx| { - this.clear_keystrokes(&ClearKeystrokes, window, cx); - })), - ), + .when(is_recording, |this| { + this.child( + IconButton::new("clear-btn", IconName::Backspace) + .shape(IconButtonShape::Square) + .tooltip(move |_, cx| { + Tooltip::with_meta( + "Clear Keystrokes", + Some(&ClearKeystrokes), + "Hit it three times to execute", + cx, + ) + }) + .when(!is_focused, |this| this.icon_color(Color::Muted)) + .on_click(cx.listener(|this, _event, window, cx| { + this.clear_keystrokes(&ClearKeystrokes, window, cx); + })), + ) + }), ) } } diff --git a/crates/ui/src/components/data_table.rs b/crates/ui/src/components/data_table.rs index 4a1f4939cca2eb85bb7a549d06af1e9ea8cf04d0..a505281cf3fa9868a19a04c168d0b1b5c71a4f85 100644 --- a/crates/ui/src/components/data_table.rs +++ b/crates/ui/src/components/data_table.rs @@ -641,11 +641,10 @@ pub fn render_table_row( .map_or([None; COLS], |widths| widths.map(Some)); let mut row = h_flex() - .h_full() .id(("table_row", row_index)) - .w_full() - .justify_between() + .size_full() .when_some(bg, |row, bg| row.bg(bg)) + .hover(|s| s.bg(cx.theme().colors().element_hover.opacity(0.6))) .when(!is_striped, |row| { row.border_b_1() .border_color(transparent_black())