Make context pills clickable while editing (#29740)

Richard Feldman , Michael , and Ben created

Release Notes:

- Fixed a bug where clicking context pills switched into the "editing
message" state instead of clicking the pill.

Co-authored-by: Michael <michael@zed.dev>
Co-authored-by: Ben <ben@zed.dev>

Change summary

crates/agent/src/ui/context_pill.rs | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

Detailed changes

crates/agent/src/ui/context_pill.rs 🔗

@@ -216,9 +216,10 @@ impl RenderOnce for ContextPill {
                     })
                     .when_some(on_click.as_ref(), |element, on_click| {
                         let on_click = on_click.clone();
-                        element
-                            .cursor_pointer()
-                            .on_click(move |event, window, cx| on_click(event, window, cx))
+                        element.cursor_pointer().on_click(move |event, window, cx| {
+                            on_click(event, window, cx);
+                            cx.stop_propagation();
+                        })
                     })
                     .into_any_element()
             }
@@ -254,7 +255,10 @@ impl RenderOnce for ContextPill {
                 })
                 .when_some(on_click.as_ref(), |element, on_click| {
                     let on_click = on_click.clone();
-                    element.on_click(move |event, window, cx| on_click(event, window, cx))
+                    element.on_click(move |event, window, cx| {
+                        on_click(event, window, cx);
+                        cx.stop_propagation();
+                    })
                 })
                 .into_any(),
         }