You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/04/29 15:36:54 UTC
[GitHub] [cordova-android] goffioul opened a new issue #722: Keyboard focus
not restored to last element on app resume
goffioul opened a new issue #722: Keyboard focus not restored to last element on app resume
URL: https://github.com/apache/cordova-android/issues/722
# Bug Report
## Problem
When resuming a cordova app, the keyboard focus is moved instead of being restored to the last focused element.
### What is expected to happen?
When the cordova app is paused and there was a focused element in the webview content, one expect the focus to be restored to that element when the app is resumed.
### What does actually happen?
The focus is moved to the first element in the page that has a non-negative tabIndex, otherwise to the document body (ignoring the elements with negative tabIndex).
## Information
This behavior has been introduced with this commit: https://github.com/apache/cordova-android/commit/c2cafb4b45fcbb307a113828dfc9f723f8a6433b
### Command or Code
- Create a new cordova app and add android platform.
- Add the following to `div.class` element in www/index.html:
```
<div id="focusable1" tabIndex="0">I am focusable</div>
<div id="focusable2" tabIndex="0">I am also focusable</div>
<input type="text">
```
- Add the following to www/css/index.css:
```
#focusable1:focus { background: yellow; }
#focusable2:focus { background: red; }
```
- Add the following to `app.receivedEvents` method in www/js/index.js:
```
document.getElementById('focusable1').focus();
```
- Compile and install the app
- On app launch, the first focusable element should have the focus, with yellow background
- Using mouse or keyboard, focus the second element, with red background
- Using adb, launch another app, e.g. `adb shell am start com.android.settings/.Settings`
- Resume cordova app, e.g. quit settings using the BACK button
Focus will be restored to the first element, with yellow background. If using `tabIndex="-1"` instead for the focusable elements, focus will be moved to the input element.
### Version information
cordova-android@7.0.0
## Checklist
<!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
- [X] I searched for existing GitHub issues
- [X] I updated all Cordova tooling to most recent version
- [X] I included all the necessary information above
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org