apache / apache/cordova-plugin-inappbrowser
[iOS] WKWebview - Back button in location bar is always enabled
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 2.2k
- PR merge metrics
- No merged PRs in 30d
Description
### Issue Type
- [x] Bug Report
## Description
Click on back button of location bar or `history.back()` or `history.go(-1)`, the back button of location bar is always enabled. User can click on back button or call `history.back()` or `history.go(-1)`, with no endpoint.
It looks like the back action always pushes new URL to history stack instead going back
## Information
I'm using `usewkwebview=yes`. When open inappbrowser in the first time, back button is disabled. But when click on some URL, the back button is always enabled.
I checked this function in CDVWKInAppBrowser.m
```
- (void)webView:(WKWebView *)theWebView didFinishNavigation:(WKNavigation *)navigation
```
`theWebView.canGoBack;` is always returns true after the first redirect
### Command or Code
```
const target = '_blank';
const options = [
'location=yes',
'hidden=no',
'hideurlbar=no',
'toolbar=yes',
'hidenavigationbuttons=no',
'zoom=no',
'transitionstyle=crossdissolve',
'enableViewportScale=yes',
'usewkwebview=yes',
'beforeload=get'
];
inAppBrowserRef = window.cordova.InAppBrowser.open(url, target, options.join());
```
### Environment, Platform, Device
Cordova ver 9
Platform: iOS 13,
Device: iPhone 7
package.json
cordova-plugin-inappbrowser: "3.1.0"
cordova-plugin-wkwebview-engine: "1.2.1"
## Checklist
- [x] I searched for already existing GitHub issues about this
- [x] I updated all Cordova tooling to their most recent version
- [x] I included all the necessary information above
Contributor guide
Research direction
Start in CDVWKInAppBrowser.m at webView:didFinishNavigation: and reproduce with usewkwebview=yes using the provided in-app browser options. Check how theWebView.canGoBack is evaluated after the first redirect and compare it with history.back() and history.go(-1). Done means the location-bar back button and history actions are disabled at the navigation endpoint and enabled only when a prior page exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, javascript, objective-c
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100