From e1d03b0894bf7803d036e304606bca6b62b47cb0 Mon Sep 17 00:00:00 2001 From: Hanjin Liu Date: Fri, 20 Sep 2024 23:00:49 +0900 Subject: [PATCH] fix scrolling on header index changed --- tabulous/_qt/_table/_base/_enhanced_table.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tabulous/_qt/_table/_base/_enhanced_table.py b/tabulous/_qt/_table/_base/_enhanced_table.py index 4b95a4a..63c1d8b 100644 --- a/tabulous/_qt/_table/_base/_enhanced_table.py +++ b/tabulous/_qt/_table/_base/_enhanced_table.py @@ -254,8 +254,13 @@ def _on_moved(self, src: Index, dst: Index) -> None: model = self.model() index_src = model.index(*src.as_uint()) index_dst = model.index(*dst.as_uint()) - if dst >= (0, 0) and self.hasFocus(): - self.scrollTo(index_dst) + if dst >= (0, 0): + if self.hasFocus(): + self.scrollTo(index_dst) + elif dst.row < 0: + self.scrollTo(model.index(0, dst.column)) + elif dst.column < 0: + self.scrollTo(model.index(dst.row, 0)) # rect is the region that needs to be updated rect: QtCore.QRect = self.visualRect(index_dst)