Skip to main content

claim_wheel

Function claim_wheel 

Source
pub fn claim_wheel<E: StatefulInteractiveElement>(
    el: E,
    handle: &ScrollHandle,
    axes: Axes,
    state: &ClaimState,
) -> E
Expand description

Let a pane keep the wheel it can act on, instead of passing it to the pane behind as well.

gpui’s scroll listener neither stops propagation nor asks whether an ancestor scrolls too, so a wheel over a nested pane moves both — an output box inside a transcript scrolls itself and drags the transcript with it (user report). Every scrolling ancestor under the pointer does this, so the deeper the nesting the further the page jumps.

The question it asks is whether the pane moved, not whether it had room to. This listener runs after the element’s own — gpui registers that one later and the bubble phase runs the list backwards — so handle already holds the post-scroll offset, and state is where it stood before. “Had room” is the same answer one notch too late, and gets the notch that lands exactly on the end wrong: the pane finishes its travel and the page jumps a full notch behind it.

Chained at the ends, not sealed: a pane with nowhere left to go hands the wheel to the page, so reaching the end of a short inner list does not strand it there and make the pointer move. A pane whose content fits never claims anything, for the same reason. For overscroll-behavior: contain — a pane that never lets a wheel past — stop unconditionally instead.

scroll::claim_wheel(
    scroll::pane("output", Axes::Vertical).track_scroll(&self.scroll),
    &self.scroll,
    Axes::Vertical,
    &self.claim,
)

axes is what the pane scrolls, and must be what pane was given: an axis left out here is one whose movement goes unnoticed, so the wheel is handed on and the ancestor moves too.