From fb332a0170ea65f40be9210b9053011c0c5b89e7 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 23 Jan 2025 11:18:25 -0500 Subject: [PATCH] git_panel: Toggle stage all when clicking changes label (#23548) When clicking the checkbox label fire the toggle action. At first I wasn't sure this is what we wanted, but after looking at a few existing implementations of checkboxes with labels it seems like this is reasonably standard. Eventually this piece of UI will be updated to a CheckboxWithLabel, but for now it is custom due to some specific style requirements. Release Notes: - N/A --- crates/git_ui/src/git_panel.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index ce862fd77f..bb665df016 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -834,7 +834,17 @@ impl GitPanel { false => git_panel.stage_all(&StageAll, cx), })), ) - .child(div().text_buffer(cx).text_ui_sm(cx).child(changes_string)), + .child( + div() + .id("changes-checkbox-label") + .text_buffer(cx) + .text_ui_sm(cx) + .child(changes_string) + .on_click(cx.listener(move |git_panel, _, cx| match all_staged { + true => git_panel.unstage_all(&UnstageAll, cx), + false => git_panel.stage_all(&StageAll, cx), + })), + ), ) .child(div().flex_grow()) .child(