@@ -479,7 +479,34 @@ void LLAccordionCtrlTab::onUpdateScrollToChild(const LLUICtrl *cntrl)
479479 // Translate to parent coordinatess to check if we are in visible rectangle
480480 rect.translate (getRect ().mLeft , getRect ().mBottom );
481481
482- if (!getRect ().contains (rect))
482+ bool needs_to_scroll = false ;
483+ const LLRect &acc_rect = getRect ();
484+ if (!acc_rect.contains (rect))
485+ {
486+ if (acc_rect.mTop < rect.mBottom || acc_rect.mBottom > rect.mTop )
487+ {
488+ // Content fully not in view
489+ needs_to_scroll = true ;
490+ }
491+ else if (acc_rect.getHeight () >= rect.getHeight ())
492+ {
493+ // Content can be displayed fully, but only partially in view
494+ needs_to_scroll = true ;
495+ }
496+ else if (acc_rect.mTop <= rect.mTop || acc_rect.mBottom >= rect.mBottom )
497+ {
498+ // Intersects, but too big to be displayed fully
499+ S32 covered_width = acc_rect.mTop > rect.mTop ? rect.mTop - acc_rect.mBottom : acc_rect.mTop - rect.mBottom ;
500+ constexpr F32 coevered_ratio = 0 .7f ;
501+ if (covered_width < coevered_ratio * acc_rect.getHeight ())
502+ {
503+ // Try to show bigger portion of the content
504+ needs_to_scroll = true ;
505+ }
506+ }
507+ // else too big and in the middle of the view as is
508+ }
509+ if (needs_to_scroll)
483510 {
484511 // for accordition's scroll, height is in pixels
485512 // Back to local coords and calculate position for scroller
0 commit comments