Files
egui/crates
Wu Shuwen 8de976f4bf Fix #8495: Match scrollbar interaction rect to drawn bar rect (remove dead zone) (#8635)
Closes #8495.

## Problem

`ScrollArea::scroll_bar_rect` is used when painting the scrollbar
(`outer_scroll_bar_rect` at lines 1360-1364) and when computing handle
geometry/travel (`from_content`, `handle_travel`), but the interaction
rect `max_bar_rect` (lines 1318-1322) was derived from `outer_rect`
along the scrolling axis.

When a caller passes a `scroll_bar_rect` smaller than `outer_rect` (as
`egui_table::SplitScroll` does to keep bars out of sticky row/column
regions), the two rects disagree along the scroll axis. Consequences:

1. A press in the region where no scrollbar is drawn is sensed as a
scrollbar press and snaps the offset to the minimum.
2. During a drag, that region behaves as a dead zone because
`scroll_start_offset_from_top_left` is latched for the whole drag and
the offset is pinned until the pointer crosses back into
`handle_travel`.

## Fix

Changed `max_bar_rect` to use `scroll_bar_rect.x_range()` for horizontal
bars and `scroll_bar_rect.y_range()` for vertical bars along the
scrolling axis, while keeping the existing cross-axis positioning
(`max_cross`, `full_width`, and the clip-rect adjustment that moves bars
into view).

The interactive region now matches the painted bar and handle travel
exactly. The default case (`scroll_bar_rect` is `None`, which resolves
to `inner_rect`) is unchanged in behavior since `inner_rect` and
`outer_rect` share the same min along the scroll axis (only the far edge
differs for scroll bar space).

- [x] `cargo check -p egui` and `cargo test -p egui` pass.
2026-10-05 13:52:23 +00:00
..