Files: a press on a download's button stays with the button
gpui runs the click of every pressed element under the pointer, so a press on a finished download's Show button also opened the file through the pressable row. The actions' box stops the press on mouse down, so the row starts no click of its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0fcde7dbbe
commit
eeeca67e55
4 files changed
+25
-4
No files matched your search
@@ -1,6 +1,6 @@
|
||||
use gpui::{
|
||||
Context, Entity, IntoElement, ParentElement, Render, SharedString, Styled, TestAppContext,
|
||||
VisualTestContext, Window, div, px,
|
||||
Context, Entity, IntoElement, Modifiers, ParentElement, Render, SharedString, Styled,
|
||||
TestAppContext, VisualTestContext, Window, div, px,
|
||||
};
|
||||
|
||||
use super::{press, settle, setup};
|
||||
@@ -255,3 +255,20 @@ fn a_download_comes_down() {
|
||||
up.upload = true;
|
||||
let _ = DownloadManager::new("downloads", [up]);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn a_press_on_show_shows_and_opens_nothing(cx: &mut TestAppContext) {
|
||||
setup(cx);
|
||||
let (host, cx) = cx.add_window_view(|_, _| Downloading { asked: Vec::new() });
|
||||
cx.update(|window, _| window.activate_window());
|
||||
settle(cx);
|
||||
let actions = cx
|
||||
.debug_bounds("transfer-actions done")
|
||||
.expect("the finished row's actions draw");
|
||||
cx.simulate_click(actions.center(), Modifiers::none());
|
||||
settle(cx);
|
||||
assert_eq!(
|
||||
host.read_with(cx, |host, _| host.asked.clone()),
|
||||
["show done"]
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use gpui::{
|
||||
AnyElement, App, ElementId, InteractiveElement, IntoElement, ParentElement, SharedString,
|
||||
StatefulInteractiveElement, Styled, Window, div, prelude::*,
|
||||
AnyElement, App, ElementId, InteractiveElement, IntoElement, MouseButton, ParentElement,
|
||||
SharedString, StatefulInteractiveElement, Styled, Window, div, prelude::*,
|
||||
};
|
||||
|
||||
use super::FileIcon;
|
||||
@@ -201,8 +201,10 @@ pub(super) fn row(id: ElementId, transfer: &Transfer, asks: &Asks, cx: &App) ->
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.debug_selector(move || format!("transfer-actions {key}"))
|
||||
.flex_none()
|
||||
.flex()
|
||||
.on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
|
||||
.children(actions.into_iter().flatten()),
|
||||
)
|
||||
.into_any_element()
|
||||
|
||||
Reference in new issue
Block a user