From 847d08f680784a3b697ec326b030e0e2f1f12646 Mon Sep 17 00:00:00 2001 From: deeplow Date: Mon, 18 Feb 2019 13:36:03 -0500 Subject: [PATCH] temporary fix for #144 --- securedrop_client/gui/widgets.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/securedrop_client/gui/widgets.py b/securedrop_client/gui/widgets.py index 4916402e8..f3f51c889 100644 --- a/securedrop_client/gui/widgets.py +++ b/securedrop_client/gui/widgets.py @@ -689,7 +689,7 @@ def __init__(self, source_db_object: Source, sdc_home: str, controller: Client, # Completely unintuitive way to ensure the view remains scrolled to the # bottom. sb = self.scroll.verticalScrollBar() - sb.rangeChanged.connect(self.move_to_bottom) + sb.rangeChanged.connect(self.update_conversation_position) main_layout = QVBoxLayout() main_layout.addWidget(self.scroll) @@ -736,12 +736,16 @@ def add_file(self, source_db_object, submission_db_object): FileWidget(source_db_object, submission_db_object, self.controller)) - def move_to_bottom(self, min_val, max_val): + def update_conversation_position(self, min_val, max_val): """ Handler called when a new item is added to the conversation. Ensures it's scrolled to the bottom and thus visible. """ - self.scroll.verticalScrollBar().setValue(max_val) + current_val = self.scroll.verticalScrollBar().value() + viewport_height = self.scroll.viewport().height() + + if current_val + viewport_height > max_val: + self.scroll.verticalScrollBar().setValue(max_val) def add_message(self, message_id: str, message: str) -> None: """