Project panel: Deselect entries on remaining blank space click + Remove hover color for selected entries (#22073)

Closes #22072

Clicking on the remaining space now allows a single click to deselect
all selected items. Check the issue for a preview of the current state
and how it works in VSCode.

Bonus: I found the hover color on selected items to be distracting. When
I have many entries selected and hover over them, it becomes hard to
tell if a particular entry is selected while the mouse pointer is on it.
This PR removes hover coloring for selected entries, mimicking how
VSCode handles it.

This PR:
<img
src="https://github.com/user-attachments/assets/9c4b20fc-df93-4868-b7fe-4045433e85b2"
alt="zed" width="450px" />

Release Notes:

- Clicking on empty space in the Project Panel now deselects all
selected items.
This commit is contained in:
tims 2024-12-16 18:35:54 +05:30 committed by GitHub
parent 38c0aa303e
commit 62b3acee5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3224,7 +3224,9 @@ impl ProjectPanel {
.border_1() .border_1()
.border_r_2() .border_r_2()
.border_color(border_color) .border_color(border_color)
.hover(|style| style.bg(bg_hover_color)) .when(!is_marked && !is_active, |div| {
div.hover(|style| style.bg(bg_hover_color))
})
.when(is_local, |div| { .when(is_local, |div| {
div.on_drag_move::<ExternalPaths>(cx.listener( div.on_drag_move::<ExternalPaths>(cx.listener(
move |this, event: &DragMoveEvent<ExternalPaths>, cx| { move |this, event: &DragMoveEvent<ExternalPaths>, cx| {
@ -3897,6 +3899,11 @@ impl Render for ProjectPanel {
this.hide_scrollbar(cx); this.hide_scrollbar(cx);
} }
})) }))
.on_click(cx.listener(|this, _event, cx| {
cx.stop_propagation();
this.selection = None;
this.marked_entries.clear();
}))
.key_context(self.dispatch_context(cx)) .key_context(self.dispatch_context(cx))
.on_action(cx.listener(Self::select_next)) .on_action(cx.listener(Self::select_next))
.on_action(cx.listener(Self::select_prev)) .on_action(cx.listener(Self::select_prev))