Skip to content

Commit

Permalink
For mozilla-mobile#12215 : Expand toolbar when url changes
Browse files Browse the repository at this point in the history
This fix allows the toolbar to be visible after the user clicks on a link and scrolls

Co-Authored-By: Mugurell <Mugurell@users.noreply.github.com>
  • Loading branch information
indurs and Mugurell committed May 31, 2022
1 parent 17fd68d commit baa112c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package mozilla.components.feature.toolbar
import androidx.annotation.VisibleForTesting
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.mapNotNull
import mozilla.components.browser.state.action.ContentAction
import mozilla.components.browser.state.selector.findCustomTabOrSelectedTab
Expand Down Expand Up @@ -47,6 +46,7 @@ class ToolbarBehaviorController(
}

if (state.content.loading) {
expandToolbar()
disableScrolling()
} else if (!state.content.loading) {
enableScrolling()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,21 @@ class ToolbarBehaviorControllerTest {

verify(controller, never()).expandToolbar()
}

@Test
fun `GIVEN the current tab is loading an url WHEN the page is scrolled THEN expand toolbar`() {
val tabContent = ContentState("loading", loading = true)
val store = BrowserStore(
BrowserState(
tabs = listOf(TabSessionState("tab_1", tabContent)),
selectedTabId = "tab_1"
)
)
val controller = spy(ToolbarBehaviorController(mock(), store))

controller.start()
shadowOf(getMainLooper()).idle()

verify(controller).expandToolbar()
}
}
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ permalink: /changelog/
* ⚠️ **This is a breaking change**: When constructing a `RemoteTabsStorage` object you must now a `Context` which is used to determine the location of the sqlite database which is used to persist the remote tabs [#11799](https://github.com/mozilla-mobile/android-components/pull/11799).
* Fixed a low frequency crasher that might occur when the app attempts to delete all history. [#12112](https://github.com/mozilla-mobile/android-components/pull/12112)

* **browser-toolbar**
* Expand toolbar when url changes
[issue # 12215](https://github.com/mozilla-mobile/android-components/issues/12215#issuecomment-1141822240)

* **feature-syncedtabs**
* ⚠️ **This is a breaking change**: When constructing a `SyncedTabsStorage`, the `tabsStorage: RemoteTabsStorage` parameter is no longer optional so must be supplied [#11799](https://github.com/mozilla-mobile/android-components/pull/11799).
Expand Down

0 comments on commit baa112c

Please sign in to comment.