diff --git a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt index a981a5e732..b6fc1cfb1b 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt @@ -117,7 +117,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope { view.browserLayout, ActionBusFactory.get(this), sessionId, (activity as HomeActivity).browsingModeManager.isPrivate, - SearchState("", isEditing = false), + SearchState("", getSessionByIdOrUseSelectedSession().searchTerms, isEditing = false), search_engine_icon ) diff --git a/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarComponent.kt b/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarComponent.kt index 003f261b10..5ecc618314 100644 --- a/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarComponent.kt +++ b/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarComponent.kt @@ -24,7 +24,7 @@ class ToolbarComponent( bus: ActionBusFactory, private val sessionId: String?, private val isPrivate: Boolean, - override var initialState: SearchState = SearchState("", false), + override var initialState: SearchState = SearchState("", "", false), private val engineIconView: ImageView? = null ) : UIComponent( @@ -73,6 +73,7 @@ class ToolbarComponent( data class SearchState( val query: String, + val searchTerm: String, val isEditing: Boolean, val engine: SearchEngine? = null ) : ViewState diff --git a/app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt b/app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt index 69474067b8..efe0c58ed7 100644 --- a/app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt @@ -52,19 +52,17 @@ class SearchFragment : Fragment() { ): View? { sessionId = SearchFragmentArgs.fromBundle(arguments!!).sessionId isPrivate = (activity as HomeActivity).browsingModeManager.isPrivate + + val session = sessionId?.let { requireComponents.core.sessionManager.findSessionById(it) } val view = inflater.inflate(R.layout.fragment_search, container, false) - val url = sessionId?.let { - requireComponents.core.sessionManager.findSessionById(it)?.let { session -> - session.url - } - } ?: "" + val url = session?.url ?: "" toolbarComponent = ToolbarComponent( view.toolbar_component_wrapper, ActionBusFactory.get(this), sessionId, isPrivate, - SearchState(url, isEditing = true), + SearchState(url, session?.searchTerms ?: "", isEditing = true), view.search_engine_icon )