From 844cbc22a0063cf6dac9cf758bb6afc8e9eac5ec Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Mon, 15 Jun 2020 18:07:31 -0400 Subject: [PATCH] more reliable focus management based on https://supernapie.com/blog/keyboard-focus-in-an-iframe/ --- src/kiri/init.js | 13 +++++++++---- src/kiri/main.js | 13 +------------ web/kiri/index.css | 7 ------- web/kiri/index.html | 1 - 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/src/kiri/init.js b/src/kiri/init.js index 050b2965..c7ac7438 100644 --- a/src/kiri/init.js +++ b/src/kiri/init.js @@ -1142,7 +1142,7 @@ }, load: $('load-file'), - focuser: $('focuser'), + // focuser: $('focuser'), container: container, rotate: $('lt-rotate'), @@ -1834,9 +1834,6 @@ // update everything dependent on the platform size platform.update_size(); - // ensure hot keys work even in iframes - API.focus(); - // restore expert setting preference API.mode.set_expert(control.expert); @@ -1882,6 +1879,14 @@ $('gdpr').style.display = 'flex'; } + // add keyboard focus handler (must use for iframes) + WIN.addEventListener('load', function () { + WIN.focus(); + DOC.body.addEventListener('click', function() { + WIN.focus(); + },false); + }); + // dismiss gdpr alert $('gotit').onclick = () => { $('gdpr').style.display = 'none'; diff --git a/src/kiri/main.js b/src/kiri/main.js index bb7d4dea..cb8ce6d6 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -152,7 +152,7 @@ js2o: js2o, ajax: ajax, clone: clone, - focus: setFocus, + focus: () => {}, stats: STATS, catalog: CATALOG, conf: { @@ -1889,17 +1889,6 @@ }); } - function setFocus(el) { - el = [ el || UI.focuser, UI.load, UI.sizeX, DOC.body ]; - for (let es, i=0; i -
loading...