aboutsummaryrefslogtreecommitdiff
path: root/src/content/focuses.js
blob: a6f6cc8a607edd9abd61704dcb43a91380f3a373 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
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 targets = window.document.querySelectorAll(inputSelector + ',textarea');
  let target = Array.from(targets).find(doms.isVisible);
  if (target) {
    target.focus();
  }
};

export { focusInput };