Fix cursor shape flickering and dead-zone on 1px border around list items in project and outline panels (#20202)

Move click listener to outer div
- Avoids dead area when clicking the 1px border around a list item
- Avoids flickering cursor shape when moving the cursor above the list,
and especially when scrolling the list with a stationary cursor.

Closes #15614

Release Notes:

- Fixed mouse cursor shape flickering in project and outline panels when
crossing items
([#15614](https://github.com/zed-industries/zed/issues/15614))

---------

Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com>
This commit is contained in:
Stephan Aßmus 2024-11-05 13:26:20 +01:00 committed by GitHub
parent 02b1e3a3c1
commit f8bd6c66f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 79 additions and 80 deletions

View file

@ -1996,6 +1996,17 @@ impl OutlinePanel {
div()
.text_ui(cx)
.id(item_id.clone())
.on_click({
let clicked_entry = rendered_entry.clone();
cx.listener(move |outline_panel, event: &gpui::ClickEvent, cx| {
if event.down.button == MouseButton::Right || event.down.first_mouse {
return;
}
let change_selection = event.down.click_count > 1;
outline_panel.open_entry(&clicked_entry, change_selection, cx);
})
})
.cursor_pointer()
.child(
ListItem::new(item_id)
.indent_level(depth)
@ -2005,16 +2016,6 @@ impl OutlinePanel {
list_item.child(h_flex().child(icon_element))
})
.child(h_flex().h_6().child(label_element).ml_1())
.on_click({
let clicked_entry = rendered_entry.clone();
cx.listener(move |outline_panel, event: &gpui::ClickEvent, cx| {
if event.down.button == MouseButton::Right || event.down.first_mouse {
return;
}
let change_selection = event.down.click_count > 1;
outline_panel.open_entry(&clicked_entry, change_selection, cx);
})
})
.on_secondary_mouse_down(cx.listener(
move |outline_panel, event: &MouseDownEvent, cx| {
// Stop propagation to prevent the catch-all context menu for the project