aboutsummaryrefslogtreecommitdiff
path: root/src/content/focuses.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-01-15 21:56:10 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2018-01-15 21:56:10 +0900
commitd1a81a877f0e7364b7d69e214ec74151d76dd25c (patch)
treefe4d02be637b7ab64615187741269f9c984d73ac /src/content/focuses.js
parent03e7e333a3183ea7bf10938c2650b1d74362589f (diff)
focus on visible elements
Diffstat (limited to 'src/content/focuses.js')
-rw-r--r--src/content/focuses.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/content/focuses.js b/src/content/focuses.js
index c2658b4..a6f6cc8 100644
--- a/src/content/focuses.js
+++ b/src/content/focuses.js
@@ -1,7 +1,10 @@
+import * as doms from 'shared/utils/dom';
+
const focusInput = () => {
let inputTypes = ['email', 'number', 'search', 'tel', 'text', 'url'];
let inputSelector = inputTypes.map(type => `input[type=${type}]`).join(',');
- let target = window.document.querySelector(inputSelector + ',textarea');
+ let targets = window.document.querySelectorAll(inputSelector + ',textarea');
+ let target = Array.from(targets).find(doms.isVisible);
if (target) {
target.focus();
}