You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AccompanistWebViewClient overrides shouldOverrideUrlLoading with
override fun shouldOverrideUrlLoading(
view: WebView?,
request: WebResourceRequest?
): Boolean {
// Override all url loads to make the single source of truth
// of the URL the state holder Url
request?.let {
state.content = state.content.withUrl(it.url.toString())
}
return true
}
Returning true ensures that the load is always cancelled here though since it's setting state.content it will normally result in the URL being loaded. However
if (url.isNotEmpty() && url != view.url) {
view.loadUrl(url, content.additionalHttpHeaders.toMutableMap())
}
in com.google.accompanist.web.WebView explicitly skips the load if the URL has not changed. This means that javascript like window.location.reload() will not reload the page.
To Reproduce
I've attached AccompanistTest.zip with a sample project demonstrating the issue.
This loads a local HTML page with a single button that should reload the page with window.location.reload(). On page load, ********PAGE LOADED******** should be written to console and is logged to logcat.
This only shows up on initial page load though, the button doesn't do anything.
Uncommenting the inelegant lines 50-52 in the sample project's MainActivity fixes the issue by avoiding the AccompanistWebViewClient.shouldOverrideUrlLoading call if the URL matches the existing URL:
if (view?.url == request?.url.toString()) {
return false
}
Expected behavior
Page should reload on window.location.reload() and other similar calls that normally cause pages to reload.
Environment:
Android OS version: Android 13
Device: P6Pro
Accompanist version: 0.25.1
The text was updated successfully, but these errors were encountered:
AccompanistWebViewClient overrides
shouldOverrideUrlLoading
withReturning
true
ensures that the load is always cancelled here though since it's settingstate.content
it will normally result in the URL being loaded. Howeverin com.google.accompanist.web.WebView explicitly skips the load if the URL has not changed. This means that javascript like
window.location.reload()
will not reload the page.To Reproduce
I've attached AccompanistTest.zip with a sample project demonstrating the issue.
This loads a local HTML page with a single button that should reload the page with
window.location.reload()
. On page load,********PAGE LOADED********
should be written to console and is logged to logcat.This only shows up on initial page load though, the button doesn't do anything.
Uncommenting the inelegant lines 50-52 in the sample project's MainActivity fixes the issue by avoiding the AccompanistWebViewClient.shouldOverrideUrlLoading call if the URL matches the existing URL:
Expected behavior
Page should reload on
window.location.reload()
and other similar calls that normally cause pages to reload.Environment:
The text was updated successfully, but these errors were encountered: