Skip to content

Commit 637e057

Browse files
authored
Fix: Voice search button not displayed when short URL configured (#6758)
Task/Issue URL: https://app.asana.com/1/137249556945/project/715106103902962/task/1211257529601162?focus=true ### Description This fixes a bug when the voice search button would not show up if full URL was disabled. ### Steps to test this PR - [x] First enable the microphone permission in the app settings - [x] Go to Settings -> General - [x] Enable the Private Voice Search toggle - [x] Go to Settings -> Appearance - [x] Disable Show Full Site Address toggle - [x] Go to the browser and navigate to some site - [x] Tap on the omnibar address bar - [x] Notice the text is focused and the voice search button is displayed
1 parent 85cf4c3 commit 637e057

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ class OmnibarLayoutViewModel @Inject constructor(
578578
showVoiceSearch = shouldShowVoiceSearch(
579579
hasFocus = hasFocus,
580580
query = query,
581-
hasQueryChanged = true,
581+
hasQueryChanged = query != updatedQuery,
582582
urlLoaded = _viewState.value.url,
583583
),
584584
)

app/src/test/java/com/duckduckgo/app/browser/omnibar/OmnibarLayoutViewModelTest.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,4 +1901,23 @@ class OmnibarLayoutViewModelTest {
19011901
expectNoEvents()
19021902
}
19031903
}
1904+
1905+
@Test
1906+
fun whenInputStateChangedAndClearingQueryThenHasQueryChangedTruePassedToVoiceSearchAvailability() = runTest {
1907+
var capturedHasQueryChanged: Boolean? = null
1908+
whenever(voiceSearchAvailability.shouldShowVoiceSearch(any(), any(), any(), any())).thenAnswer { invocation ->
1909+
capturedHasQueryChanged = invocation.getArgument(2)
1910+
true
1911+
}
1912+
1913+
// First set a non-empty query
1914+
testee.onInputStateChanged("initial", hasFocus = true, clearQuery = false, deleteLastCharacter = false)
1915+
// Then clear the query which should set hasQueryChanged = true because updatedQuery retains previous value
1916+
testee.onInputStateChanged("", hasFocus = true, clearQuery = true, deleteLastCharacter = false)
1917+
1918+
testee.viewState.test {
1919+
awaitItem()
1920+
assertTrue(capturedHasQueryChanged == true)
1921+
}
1922+
}
19041923
}

0 commit comments

Comments
 (0)