From e8cbd586a91e8bd787fa42e28ece62ca3affc75b Mon Sep 17 00:00:00 2001
From: Eugene Mutavchi <emutavchi@productengine.com>
Date: Mon, 18 Jan 2010 17:10:11 +0200
Subject: [PATCH] Fixed normal bug EXT-4379 (Scroller doesn't follow the cursor
 if cursor is being moved by keyboard arrow buttons)

--HG--
branch : product-engine
---
 indra/llui/llflatlistview.cpp    | 9 +--------
 indra/llui/llscrollcontainer.cpp | 5 +++++
 indra/newview/llfolderview.cpp   | 4 ++--
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp
index 9cfc67af147..3694ecd4f49 100644
--- a/indra/llui/llflatlistview.cpp
+++ b/indra/llui/llflatlistview.cpp
@@ -711,19 +711,12 @@ void LLFlatListView::selectLastItem		()
 
 void LLFlatListView::ensureSelectedVisible()
 {
-	LLRect visible_rc = getVisibleContentRect();
 	LLRect selected_rc = getLastSelectedItemRect();
 
-	if ( !visible_rc.contains (selected_rc) )
+	if ( selected_rc.isValid() )
 	{
-		// But scroll in Items panel coordinates
 		scrollToShowRect(selected_rc);
 	}
-
-	// In case we are in accordion tab notify parent to show selected rectangle
-	LLRect screen_rc;
-	localRectToScreen(selected_rc, &screen_rc);
-	notifyParent(LLSD().with("scrollToShowRect",screen_rc.getValue()));
 }
 
 
diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp
index a5e47e8547f..94465a67cea 100644
--- a/indra/llui/llscrollcontainer.cpp
+++ b/indra/llui/llscrollcontainer.cpp
@@ -668,6 +668,11 @@ void LLScrollContainer::scrollToShowRect(const LLRect& rect, const LLRect& const
 
 	// propagate scroll to document
 	updateScroll();
+
+	// In case we are in accordion tab notify parent to show selected rectangle
+	LLRect screen_rc;
+	localRectToScreen(rect_to_constrain, &screen_rc);
+	notifyParent(LLSD().with("scrollToShowRect",screen_rc.getValue()));
 }
 
 void LLScrollContainer::pageUp(S32 overlap)
diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index afde543ca86..a63fb730320 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -1885,8 +1885,8 @@ void LLFolderView::scrollToShowItem(LLFolderViewItem* item, const LLRect& constr
 		
 		S32 icon_height = mIcon.isNull() ? 0 : mIcon->getHeight(); 
 		S32 label_height = llround(getLabelFontForStyle(mLabelStyle)->getLineHeight()); 
-		// when navigating with keyboard, only move top of folders on screen, otherwise show whole folder
-		S32 max_height_to_show = mScrollContainer->hasFocus() ? (llmax( icon_height, label_height ) + ICON_PAD) : local_rect.getHeight(); 
+		// when navigating with keyboard, only move top of opened folder on screen, otherwise show whole folder
+		S32 max_height_to_show = item->isOpen() && mScrollContainer->hasFocus() ? (llmax( icon_height, label_height ) + ICON_PAD) : local_rect.getHeight(); 
 		
 		// get portion of item that we want to see...
 		LLRect item_local_rect = LLRect(item->getIndentation(), 
-- 
GitLab