mirror of
https://github.com/keeweb/keeweb.git
synced 2024-06-27 07:45:08 +02:00
Only focuses input field when app or browser is active on lock. Fixes #423
This commit is contained in:
parent
f18d053cbf
commit
69e079c319
11
app/scripts/util/browser-focus.js
Normal file
11
app/scripts/util/browser-focus.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
const BrowserFocus = function () {
|
||||
this.isFocused = false;
|
||||
window.onblur = function () { this.isFocused = false; }.bind(this);
|
||||
window.onfocus = function () { this.isFocused = true; }.bind(this);
|
||||
};
|
||||
|
||||
BrowserFocus.prototype.hasFocus = function () {
|
||||
return this.isFocused;
|
||||
};
|
||||
|
||||
module.exports = BrowserFocus;
|
|
@ -15,6 +15,7 @@ const InputFx = require('../util/input-fx');
|
|||
const Comparators = require('../util/comparators');
|
||||
const Storage = require('../storage');
|
||||
const Launcher = require('../comp/launcher');
|
||||
const BrowserFocus = require('../util/browser-focus');
|
||||
|
||||
const logger = new Logger('open-view');
|
||||
|
||||
|
@ -69,6 +70,9 @@ const OpenView = Backbone.View.extend({
|
|||
KeyHandler.onKey(Keys.DOM_VK_RETURN, this.enterKeyPress, this);
|
||||
KeyHandler.onKey(Keys.DOM_VK_DOWN, this.moveOpenFileSelectionDown, this);
|
||||
KeyHandler.onKey(Keys.DOM_VK_UP, this.moveOpenFileSelectionUp, this);
|
||||
if (!FeatureDetector.isDesktop) {
|
||||
this.browserFocus = new BrowserFocus();
|
||||
}
|
||||
},
|
||||
|
||||
render: function () {
|
||||
|
@ -107,7 +111,12 @@ const OpenView = Backbone.View.extend({
|
|||
|
||||
focusInput: function() {
|
||||
if (!FeatureDetector.isMobile) {
|
||||
this.inputEl.focus();
|
||||
if (
|
||||
(FeatureDetector.isDesktop && Launcher.isAppFocused()) ||
|
||||
(this.browserFocus.hasFocus())
|
||||
) {
|
||||
this.inputEl.focus();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user