diff --git a/src/app/tile/elm.rs b/src/app/tile/elm.rs index 8c1794a..d356320 100644 --- a/src/app/tile/elm.rs +++ b/src/app/tile/elm.rs @@ -112,12 +112,7 @@ pub fn view(tile: &Tile, wid: window::Id) -> Element<'_, Message> { .padding(20); let scrollbar_direction = if tile.config.theme.show_scroll_bar { - let anchor = if tile.focus_id > 4 { - Anchor::End - } else { - Anchor::Start - }; - Direction::Vertical(Scrollbar::new().width(2).scroller_width(2).anchor(anchor)) + Direction::Vertical(Scrollbar::new().width(2).scroller_width(2)) } else { Direction::Vertical(Scrollbar::hidden()) }; @@ -141,7 +136,7 @@ pub fn view(tile: &Tile, wid: window::Id) -> Element<'_, Message> { clipboard_history } }; - let scrollable = Scrollable::with_direction(results, scrollbar_direction); + let scrollable = Scrollable::with_direction(results, scrollbar_direction).id("results"); let contents = Column::new().push(title_input).push(scrollable); container(contents) diff --git a/src/app/tile/update.rs b/src/app/tile/update.rs index 3515174..3d05afd 100644 --- a/src/app/tile/update.rs +++ b/src/app/tile/update.rs @@ -9,6 +9,7 @@ use global_hotkey::hotkey::HotKey; use iced::Task; use iced::widget::image::Handle; use iced::widget::operation; +use iced::widget::operation::AbsoluteOffset; use iced::window; use rayon::iter::IntoParallelRefIterator; use rayon::iter::ParallelIterator; @@ -219,7 +220,13 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task { _ => {} } - operation::focus(format!("result-{}", tile.focus_id)) + operation::scroll_to( + "results", + AbsoluteOffset { + x: None, + y: Some(tile.focus_id as f32 * 55.), + }, + ) } else { Task::none() }