@ -157,9 +157,6 @@ class TabTrayView(
val tabs = getTabs ( isPrivate )
val selectedBrowserTabIndex = tabs
. indexOfFirst { it . id == view . context . components . core . store . state . selectedTabId }
updateBottomSheetBehavior ( )
setTopOffset ( isInLandscape ( ) )
@ -208,14 +205,14 @@ class TabTrayView(
}
if ( ! hasLoaded ) {
hasLoaded = true
scrollTo Tab( view . context . components . core . store . state . selectedTabId )
scrollTo SelectedBrowserTab( )
if ( view . context . settings ( ) . accessibilityServicesEnabled ) {
lifecycleScope . launch {
delay ( SELECTION_DELAY . toLong ( ) )
lifecycleScope . launch ( Main ) {
layoutManager ?. findViewByPosition ( selectedBrowserTabIndex )
layoutManager ?. findViewByPosition ( getSelectedBrowserTabViewIndex( ) )
?. requestFocus ( )
layoutManager ?. findViewByPosition ( selectedBrowserTabIndex )
layoutManager ?. findViewByPosition ( getSelectedBrowserTabViewIndex( ) )
?. sendAccessibilityEvent (
AccessibilityEvent . TYPE _VIEW _FOCUSED
)
@ -367,7 +364,7 @@ class TabTrayView(
toggleSaveToCollectionButton ( isPrivateModeSelected )
updateUINormalMode ( view . context . components . core . store . state )
scrollTo Tab( view . context . components . core . store . state . selectedTabId )
scrollTo SelectedBrowserTab( )
if ( isPrivateModeSelected ) {
components . analytics . metrics . track ( Event . TabsTrayPrivateModeTapped )
@ -682,28 +679,39 @@ class TabTrayView(
return interactor . onBackPressed ( )
}
fun scrollTo Tab( sessionId : String ? ) {
fun scrollTo SelectedBrowserTab( selectedTabId : String ? = null ) {
view . tabsTray . apply {
val recyclerViewIndex = getSelectedBrowserTabViewIndex ( selectedTabId )
layoutManager ?. scrollToPosition ( recyclerViewIndex )
smoothScrollBy (
0 ,
- resources . getDimensionPixelSize ( R . dimen . tab _tray _tab _item _height ) / 2
)
}
}
private fun getSelectedBrowserTabViewIndex ( sessionId : String ? = null ) : Int {
val tabs = if ( isPrivateModeSelected ) {
view . context . components . core . store . state . privateTabs
} else {
view . context . components . core . store . state . normalTabs
}
val selectedBrowserTabIndex = tabs
. indexOfFirst { it . id == sessionId }
val selectedBrowserTabIndex = if ( sessionId != null ) {
tabs . indexOfFirst { it . id == sessionId }
} else {
tabs . indexOfFirst { it . id == view . context . components . core . store . state . selectedTabId }
}
// We offset the tab index by the number of items in the other adapters.
// We add the offset, because the layoutManager is initialized with `reverseLayout`.
val recyclerViewIndex = selectedBrowserTabIndex +
return if ( view . context . settings ( ) . listTabView ) {
selectedBrowserTabIndex +
collectionsButtonAdapter . itemCount +
syncedTabsController . adapter . itemCount
layoutManager ?. scrollToPosition ( recyclerViewIndex )
smoothScrollBy (
0 ,
- resources . getDimensionPixelSize ( R . dimen . tab _tray _tab _item _height ) / 2
)
} else {
selectedBrowserTabIndex
}
}