Skip to content

Commit

Permalink
For mozilla-mobile#12215: Expand toolbar when the page is loading.
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.
  • Loading branch information
indurs authored and Mugurell committed May 31, 2022
1 parent 8732feb commit 10c137e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
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()
}
}
4 changes: 3 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ permalink: /changelog/
* [Gecko](https://github.com/mozilla-mobile/android-components/blob/main/buildSrc/src/main/java/Gecko.kt)
* [Configuration](https://github.com/mozilla-mobile/android-components/blob/main/.config.yml)

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

* **service-pocket**
* Ensure sponsored stories profile deletion is retried in background until successful or the feature is re-enabled. [#12258](https://github.com/mozilla-mobile/android-components/issues/12258)

Expand Down Expand Up @@ -79,7 +82,6 @@ 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)


* **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 10c137e

Please sign in to comment.