input: Avoid blocking vertical scroll events in single-line mode (#1562) (#1572)

Fixes #1562

  ## Problem
Single-line input fields were blocking all scroll wheel events,
preventing parent containers from handling vertical page scrolling.

  ## Solution
  - Check if input is in single-line mode and scroll is purely vertical
  - Allow vertical scroll events to propagate in single-line mode
  - Only stop propagation when scroll offset actually changes

  ## Behavior
  - Single-line inputs: vertical scroll passes through to parent
  - Multi-line inputs: all scroll behavior unchanged
  - Horizontal scrolling still works in both modes
This commit is contained in:
chulingera2025 2025-11-13 10:19:52 +08:00 committed by GitHub
parent 3ef1ce3d3e
commit d4c4b9ad37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1291,15 +1291,21 @@ impl InputState {
window: &mut Window,
cx: &mut Context<Self>,
) {
cx.stop_propagation();
let line_height = self
.last_layout
.as_ref()
.map(|layout| layout.line_height)
.unwrap_or(window.line_height());
let delta = event.delta.pixel_delta(line_height);
self.update_scroll_offset(Some(self.scroll_handle.offset() + delta), cx);
let old_offset = self.scroll_handle.offset();
self.update_scroll_offset(Some(old_offset + delta), cx);
// Only stop propagation if the offset actually changed
if self.scroll_handle.offset() != old_offset {
cx.stop_propagation();
}
self.diagnostic_popover = None;
}