Skip to content

Commit f09abc7

Browse files
authored
do not change address bar content if no query was made in the Duck.ai Input Screen (#6306)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1208671518894266/task/1210657930367705?focus=true ### Description Revert back to the original omnibar content if Duck.ai Input screen query was not submitted. ### Steps to test this PR - [ ] Go to any website - [ ] Open input screen and change content - [ ] Go back - [ ] Verify the website URL is restored in the omnibar
1 parent 123268a commit f09abc7

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ class BrowserTabFragment :
873873
if (result.resultCode == RESULT_OK) {
874874
submitQuery(query)
875875
} else {
876-
omnibar.setText(query)
876+
omnibar.setDraftTextIfNtp(query)
877877
}
878878
}
879879

app/src/main/java/com/duckduckgo/app/browser/omnibar/Omnibar.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,10 @@ class Omnibar(
463463
) {
464464
newOmnibar.decorate(Decoration.NewTabScrollingState(canScrollUp, canScrollDown, topOfPage))
465465
}
466+
467+
fun setDraftTextIfNtp(query: String) {
468+
newOmnibar.setDraftTextIfNtp(query)
469+
}
466470
}
467471

468472
fun VisualDesignExperimentDataStore.getOmnibarType(): OmnibarType {

app/src/main/java/com/duckduckgo/app/browser/omnibar/OmnibarLayout.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,4 +1037,8 @@ open class OmnibarLayout @JvmOverloads constructor(
10371037
override fun onAnimationFinished() {
10381038
omnibarTextListener?.onTrackersCountFinished()
10391039
}
1040+
1041+
fun setDraftTextIfNtp(query: String) {
1042+
viewModel.setDraftTextIfNtp(query)
1043+
}
10401044
}

app/src/main/java/com/duckduckgo/app/browser/omnibar/OmnibarLayoutViewModel.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,4 +826,15 @@ class OmnibarLayoutViewModel @Inject constructor(
826826
// }
827827
// }
828828
}
829+
830+
fun setDraftTextIfNtp(query: String) {
831+
if (_viewState.value.viewMode is NewTab) {
832+
_viewState.update {
833+
it.copy(
834+
omnibarText = query,
835+
updateOmnibarText = true,
836+
)
837+
}
838+
}
839+
}
829840
}

0 commit comments

Comments
 (0)