From 86a757237ec4f455911738428d36e462ca9fdabf Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Wed, 11 Mar 2026 00:30:57 +0100 Subject: [PATCH] ui: Add close and confirm button to breakpoint edit prompt block (#51239) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a problem with our breakpoint prompt edit component where there was no way through the mouse to close/confirm the edit a user was making. ### Before image ### After Screenshot 2026-03-11 at 12 16 38 AM Before you mark this PR as ready for review, make sure that you have: - [ ] Added a solid test coverage and/or screenshots from doing manual testing - [x] Done a self-review taking into account security and performance aspects - [x] Aligned any UI changes with the [UI checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) Release Notes: - N/A --- crates/editor/src/editor.rs | 58 +++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 28c200c22ab01f6e691ea52d6463c9d8be530e8c..aabf16d2b64846388b6b1c0903e280e9f465a41d 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -209,6 +209,7 @@ use theme::{ use ui::{ Avatar, ButtonSize, ButtonStyle, ContextMenu, Disclosure, IconButton, IconButtonShape, IconName, IconSize, Indicator, Key, Tooltip, h_flex, prelude::*, scrollbars::ScrollbarAutoHide, + utils::WithRemSize, }; use ui_input::ErasedEditor; use util::{RangeExt, ResultExt, TryFutureExt, maybe, post_inc}; @@ -29064,12 +29065,41 @@ impl BreakpointPromptEditor { }, ) } + + fn render_close_button(&self, cx: &mut Context) -> impl IntoElement { + let focus_handle = self.prompt.focus_handle(cx); + IconButton::new("cancel", IconName::Close) + .icon_color(Color::Muted) + .shape(IconButtonShape::Square) + .tooltip(move |_window, cx| { + Tooltip::for_action_in("Cancel", &menu::Cancel, &focus_handle, cx) + }) + .on_click(cx.listener(|this, _, window, cx| { + this.cancel(&menu::Cancel, window, cx); + })) + } + + fn render_confirm_button(&self, cx: &mut Context) -> impl IntoElement { + let focus_handle = self.prompt.focus_handle(cx); + IconButton::new("confirm", IconName::Return) + .icon_color(Color::Muted) + .shape(IconButtonShape::Square) + .tooltip(move |_window, cx| { + Tooltip::for_action_in("Confirm", &menu::Confirm, &focus_handle, cx) + }) + .on_click(cx.listener(|this, _, window, cx| { + this.confirm(&menu::Confirm, window, cx); + })) + } } impl Render for BreakpointPromptEditor { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { + let ui_font_size = ThemeSettings::get_global(cx).ui_font_size(cx); let editor_margins = *self.editor_margins.lock(); let gutter_dimensions = editor_margins.gutter; + let left_gutter_width = gutter_dimensions.full_width() + (gutter_dimensions.margin / 2.0); + let right_padding = editor_margins.right + px(9.); h_flex() .key_context("Editor") .bg(cx.theme().colors().editor_background) @@ -29077,10 +29107,34 @@ impl Render for BreakpointPromptEditor { .border_color(cx.theme().status().info_border) .size_full() .py(window.line_height() / 2.5) + .pr(right_padding) .on_action(cx.listener(Self::confirm)) .on_action(cx.listener(Self::cancel)) - .child(h_flex().w(gutter_dimensions.full_width() + (gutter_dimensions.margin / 2.0))) - .child(div().flex_1().child(self.render_prompt_editor(cx))) + .child( + WithRemSize::new(ui_font_size) + .h_full() + .w(left_gutter_width) + .flex() + .flex_row() + .flex_shrink_0() + .items_center() + .justify_center() + .gap_1() + .child(self.render_close_button(cx)), + ) + .child( + h_flex() + .w_full() + .justify_between() + .child(div().flex_1().child(self.render_prompt_editor(cx))) + .child( + WithRemSize::new(ui_font_size) + .flex() + .flex_row() + .items_center() + .child(self.render_confirm_button(cx)), + ), + ) } }