mirror of
https://github.com/zed-industries/zed.git
synced 2026-05-31 19:05:00 +07:00
Fix scrollbar track clicks in project panel and settings
Add `ReservedSpace::OverlayTrack` to the scrollbar component: a track hitbox that intercepts clicks without reserving layout space. This differs from `Track` (reserves padding when scrollable) and `StableTrack` (always reserves padding). Project panel previously had no vertical track, so clicks below/above the thumb fell through to tree items. Settings used `Thumb`-only, so track clicks did nothing and fell through to settings items. Both now use `with_overlay_track_along` so track clicks scroll correctly without causing layout asymmetry. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d2953a2b57
commit
e3d5bcb0df
3 changed files with 19 additions and 7 deletions
|
|
@ -7089,12 +7089,11 @@ impl Render for ProjectPanel {
|
|||
{
|
||||
let mut scrollbars =
|
||||
Scrollbars::for_settings::<ProjectPanelScrollbarProxy>()
|
||||
.tracked_scroll_handle(&self.scroll_handle);
|
||||
.tracked_scroll_handle(&self.scroll_handle)
|
||||
.with_overlay_track_along(ScrollAxes::Vertical);
|
||||
if horizontal_scroll {
|
||||
scrollbars = scrollbars.with_track_along(
|
||||
ScrollAxes::Horizontal,
|
||||
cx.theme().colors().panel_background,
|
||||
);
|
||||
scrollbars =
|
||||
scrollbars.with_overlay_track_along(ScrollAxes::Horizontal);
|
||||
}
|
||||
scrollbars.notify_content()
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3477,12 +3477,19 @@ impl SettingsWindow {
|
|||
window.focus_prev(cx);
|
||||
}))
|
||||
.when(current_sub_page.is_none(), |this| {
|
||||
this.vertical_scrollbar_for(&self.list_state, window, cx)
|
||||
this.custom_scrollbars(
|
||||
Scrollbars::new(ui::ScrollAxes::Vertical)
|
||||
.tracked_scroll_handle(&self.list_state)
|
||||
.with_overlay_track_along(ui::ScrollAxes::Vertical),
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
.when_some(current_sub_page, |this, current_sub_page| {
|
||||
this.custom_scrollbars(
|
||||
Scrollbars::new(ui::ScrollAxes::Vertical)
|
||||
.tracked_scroll_handle(¤t_sub_page.scroll_handle)
|
||||
.with_overlay_track_along(ui::ScrollAxes::Vertical)
|
||||
.id((current_sub_page.link.title.clone(), 42)),
|
||||
window,
|
||||
cx,
|
||||
|
|
|
|||
|
|
@ -321,6 +321,7 @@ enum ReservedSpace {
|
|||
None,
|
||||
Thumb,
|
||||
Track,
|
||||
OverlayTrack,
|
||||
StableTrack,
|
||||
}
|
||||
|
||||
|
|
@ -330,7 +331,7 @@ impl ReservedSpace {
|
|||
}
|
||||
|
||||
fn needs_scroll_track(&self) -> bool {
|
||||
matches!(self, Self::Track | Self::StableTrack)
|
||||
matches!(self, Self::Track | Self::OverlayTrack | Self::StableTrack)
|
||||
}
|
||||
|
||||
fn needs_space_reserved(&self, max_offset: Pixels) -> bool {
|
||||
|
|
@ -473,6 +474,11 @@ impl<ScrollHandle: ScrollableHandle> Scrollbars<ScrollHandle> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_overlay_track_along(mut self, along: ScrollAxes) -> Self {
|
||||
self.visibility = along.apply_to(self.visibility, ReservedSpace::OverlayTrack);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_stable_track_along(mut self, along: ScrollAxes, background_color: Hsla) -> Self {
|
||||
self.visibility = along.apply_to(self.visibility, ReservedSpace::StableTrack);
|
||||
self.track_color = Some(background_color);
|
||||
|
|
|
|||
Loading…
Reference in a new issue