focus on visible elements
This commit is contained in:
parent
03e7e333a3
commit
d1a81a877f
3 changed files with 30 additions and 23 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Reference in a new issue