From b75b5017e1b07f4b74f40d70ef8a0c9c7183578b Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Mon, 17 Aug 2020 10:50:33 -0700 Subject: [PATCH] ScrollView: Do not change offset in directionless focus change --- cursive-core/src/views/scroll_view.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cursive-core/src/views/scroll_view.rs b/cursive-core/src/views/scroll_view.rs index 4c59d27..e9f55be 100644 --- a/cursive-core/src/views/scroll_view.rs +++ b/cursive-core/src/views/scroll_view.rs @@ -370,10 +370,13 @@ where fn take_focus(&mut self, source: Direction) -> bool { // If the inner view takes focus, re-align the important area. if self.inner.take_focus(source) { - self.scroll_to_important_area(); + // Don't do anything if we come from `None` + if source != Direction::none() { + self.scroll_to_important_area(); - // Note: we can't really return an `EventResult` here :( - self.on_scroll_callback(); + // Note: we can't really return an `EventResult` here :( + self.on_scroll_callback(); + } true } else { self.core.is_scrolling().any()