commit 6db6cf7b7a2c256b30ff1781714c4c22525c70c8
parent 0bc32272d2ab7cafc398681f93025ff819b41070
Author: kernelkind <kernelkind@gmail.com>
Date: Thu, 24 Jul 2025 09:42:46 -0600
enforce scroll_id for `ThreadView`
Signed-off-by: kernelkind <kernelkind@gmail.com>
Diffstat:
2 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/crates/notedeck_columns/src/timeline/route.rs b/crates/notedeck_columns/src/timeline/route.rs
@@ -87,8 +87,8 @@ pub fn render_thread_route(
note_options,
note_context,
jobs,
+ col,
)
- .id_source(col)
.ui(ui)
.map(Into::into)
}
diff --git a/crates/notedeck_columns/src/ui/thread.rs b/crates/notedeck_columns/src/ui/thread.rs
@@ -14,7 +14,6 @@ pub struct ThreadView<'a, 'd> {
selected_note_id: &'a [u8; 32],
note_options: NoteOptions,
col: usize,
- id_source: egui::Id,
note_context: &'a mut NoteContext<'d>,
jobs: &'a mut JobsCache,
}
@@ -27,37 +26,33 @@ impl<'a, 'd> ThreadView<'a, 'd> {
note_options: NoteOptions,
note_context: &'a mut NoteContext<'d>,
jobs: &'a mut JobsCache,
+ col: usize,
) -> Self {
- let id_source = egui::Id::new("threadscroll_threadview");
ThreadView {
threads,
selected_note_id,
note_options,
- id_source,
note_context,
jobs,
- col: 0,
+ col,
}
}
- pub fn id_source(mut self, col: usize) -> Self {
- self.col = col;
- self.id_source = egui::Id::new(("threadscroll", col));
- self
+ pub fn scroll_id(selected_note_id: &[u8; 32], col: usize) -> egui::Id {
+ egui::Id::new(("threadscroll", selected_note_id, col))
}
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<NoteAction> {
let txn = Transaction::new(self.note_context.ndb).expect("txn");
+ let scroll_id = ThreadView::scroll_id(self.selected_note_id, self.col);
let mut scroll_area = egui::ScrollArea::vertical()
- .id_salt(self.id_source)
+ .id_salt(scroll_id)
.animated(false)
.auto_shrink([false, false])
.scroll_bar_visibility(egui::scroll_area::ScrollBarVisibility::AlwaysVisible);
- let offset_id = self
- .id_source
- .with(("scroll_offset", self.selected_note_id));
+ let offset_id = scroll_id.with(("scroll_offset", self.selected_note_id));
if let Some(offset) = ui.data(|i| i.get_temp::<f32>(offset_id)) {
scroll_area = scroll_area.vertical_scroll_offset(offset);