From 242d5e239d0c1ace2352191ae2692651d08268de Mon Sep 17 00:00:00 2001 From: Crizant Lai Date: Thu, 29 Oct 2026 17:51:54 +1000 Subject: [PATCH] fix(desktop): prevent hover styling on disabled manager actions - Add disabled-aware icon and remove-row button helpers - Apply them to environment and certificate manager actions --- crates/desktop/src/app/chrome/certificates.rs | 26 +++++++------- crates/desktop/src/app/chrome/environments.rs | 32 ++++++++--------- crates/desktop/src/components/controls.rs | 3 +- .../src/components/controls/buttons.rs | 35 +++++++++++++++++-- crates/desktop/src/components/mod.rs | 5 +-- 5 files changed, 64 insertions(+), 37 deletions(-) diff --git a/crates/desktop/src/app/chrome/certificates.rs b/crates/desktop/src/app/chrome/certificates.rs index f4e2d3b1..c1915135 100644 --- a/crates/desktop/src/app/chrome/certificates.rs +++ b/crates/desktop/src/app/chrome/certificates.rs @@ -218,11 +218,12 @@ impl ProbeApp { .flex() .items_center() .child( - components::icon_button( + components::icon_button_with_disabled( theme, format!("certificate-up-{index}"), CERTIFICATE_MOVE_UP, components::reorder_icon(theme, true), + busy || index == 0, move |_, _, cx| { let _ = up.update(cx, |view, cx| { view.apply_environment_manager_draft(cx, |dialog| { @@ -233,15 +234,15 @@ impl ProbeApp { }); }, ) - .flex_none() - .disabled(busy || index == 0), + .flex_none(), ) .child( - components::icon_button( + components::icon_button_with_disabled( theme, format!("certificate-down-{index}"), CERTIFICATE_MOVE_DOWN, components::reorder_icon(theme, false), + busy || index + 1 == dialog.draft().client_certificates.len(), move |_, _, cx| { let _ = down.update(cx, |view, cx| { view.apply_environment_manager_draft(cx, |dialog| { @@ -250,31 +251,29 @@ impl ProbeApp { }); }, ) - .flex_none() - .disabled( - busy || index + 1 == dialog.draft().client_certificates.len(), - ), + .flex_none(), ) .child( - components::icon_button( + components::icon_button_with_disabled( theme, format!("certificate-edit-{index}"), format!("Edit certificate for {domain}"), components::edit_icon(theme), + busy, move |_, window, cx| { let _ = edit.update(cx, |view, cx| { view.open_certificate_editor(Some(index), window, cx) }); }, ) - .flex_none() - .disabled(busy), + .flex_none(), ) .child( - components::remove_row_button( + components::remove_row_button_with_disabled( theme, format!("certificate-delete-{index}"), format!("Remove certificate for {domain}"), + busy, move |_, _, cx| { let _ = delete.update(cx, |view, cx| { view.apply_environment_manager_draft(cx, |dialog| { @@ -283,8 +282,7 @@ impl ProbeApp { }); }, ) - .flex_none() - .disabled(busy), + .flex_none(), ), ), ); diff --git a/crates/desktop/src/app/chrome/environments.rs b/crates/desktop/src/app/chrome/environments.rs index 34fc7c05..7400550a 100644 --- a/crates/desktop/src/app/chrome/environments.rs +++ b/crates/desktop/src/app/chrome/environments.rs @@ -145,7 +145,7 @@ impl ProbeApp { .child( Popover::new("environment-manager-add-menu") .trigger( - components::icon_button( + components::icon_button_with_disabled( theme, "environment-manager-add", add_label, @@ -154,10 +154,10 @@ impl ProbeApp { } else { theme.colors.text.secondary }), + add_disabled, |_, _, _| {}, ) - .flex_none() - .disabled(add_disabled), + .flex_none(), ) .content(move |_, _, cx| { let create_menu = cx.weak_entity(); @@ -524,21 +524,19 @@ impl ProbeApp { }), ); row_element = if let Some(index) = direct_index { - row_element.child( - components::remove_row_button( - theme, - format!("environment-variable-delete-{row_id}"), - format!("Remove {name} from this environment"), - move |_, _, cx| { - let _ = remove_view.update(cx, |view, cx| { - view.apply_environment_manager_draft(cx, |dialog| { - dialog.remove_variable(index); - }); + row_element.child(components::remove_row_button_with_disabled( + theme, + format!("environment-variable-delete-{row_id}"), + format!("Remove {name} from this environment"), + busy, + move |_, _, cx| { + let _ = remove_view.update(cx, |view, cx| { + view.apply_environment_manager_draft(cx, |dialog| { + dialog.remove_variable(index); }); - }, - ) - .disabled(busy), - ) + }); + }, + )) } else { row_element.child(div().w(px(32.0))) }; diff --git a/crates/desktop/src/components/controls.rs b/crates/desktop/src/components/controls.rs index eddec1ac..34676b3e 100644 --- a/crates/desktop/src/components/controls.rs +++ b/crates/desktop/src/components/controls.rs @@ -6,7 +6,8 @@ mod input; pub(crate) use buttons::{ browse_file_button, compact_icon_button, editor_action_button, editor_add_button, - editor_button, editor_key_value_row, editor_subtab, icon_button, remove_row_button, text_tab, + editor_button, editor_key_value_row, editor_subtab, icon_button, icon_button_with_disabled, + remove_row_button, remove_row_button_with_disabled, text_tab, }; pub(crate) use dropdown::{dropdown, dropdown_with_option_colors}; pub(super) use input::{ diff --git a/crates/desktop/src/components/controls/buttons.rs b/crates/desktop/src/components/controls/buttons.rs index 0a9d4fbd..15e359ff 100644 --- a/crates/desktop/src/components/controls/buttons.rs +++ b/crates/desktop/src/components/controls/buttons.rs @@ -177,11 +177,22 @@ pub(crate) fn remove_row_button( aria_label: impl Into, on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, ) -> Button { - icon_button( + remove_row_button_with_disabled(theme, id, aria_label, false, on_click) +} + +pub(crate) fn remove_row_button_with_disabled( + theme: Theme, + id: impl Into, + aria_label: impl Into, + disabled: bool, + on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, +) -> Button { + icon_button_with_disabled( theme, id, aria_label, trash_icon(theme.colors.text.secondary), + disabled, on_click, ) } @@ -207,6 +218,19 @@ pub(crate) fn icon_button( aria_label: impl Into, icon: impl IntoElement, on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, +) -> Button { + icon_button_with_disabled(theme, id, aria_label, icon, false, on_click) +} + +// Choose hover styling here: Button's disabled semantic styles cannot remove +// GPUI hover styles after they have been attached. +pub(crate) fn icon_button_with_disabled( + theme: Theme, + id: impl Into, + aria_label: impl Into, + icon: impl IntoElement, + disabled: bool, + on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, ) -> Button { let id = id.into(); let debug_id = id.to_string(); @@ -224,8 +248,13 @@ pub(crate) fn icon_button( .bg(transparent_black()) .border_1() .border_color(transparent_black()) - .cursor_pointer() - .hover(move |button| button.bg(theme.colors.selection.inactive_background)) + .disabled(disabled) + .when(disabled, |button| button.cursor_default()) + .when(!disabled, |button| { + button + .cursor_pointer() + .hover(move |button| button.bg(theme.colors.selection.inactive_background)) + }) .focus_visible(move |button| button.border_color(theme.colors.borders.focused)) .on_click(on_click) .child(icon) diff --git a/crates/desktop/src/components/mod.rs b/crates/desktop/src/components/mod.rs index 7f395f6c..331f221f 100644 --- a/crates/desktop/src/components/mod.rs +++ b/crates/desktop/src/components/mod.rs @@ -42,8 +42,9 @@ pub(crate) use controls::{ FieldInput, ListScroll, ListScrollState, ResponseBodyInputOptions, browse_file_button, compact_icon_button, dialog_text_input, dropdown, dropdown_with_option_colors, editor_action_button, editor_add_button, editor_button, editor_key_value_row, editor_subtab, - icon_button, list_scroll_region, remove_row_button, sidebar_search_input, text_tab, - url_text_input, variable_text_input, + icon_button, icon_button_with_disabled, list_scroll_region, remove_row_button, + remove_row_button_with_disabled, sidebar_search_input, text_tab, url_text_input, + variable_text_input, }; mod icons;