implement focus input
This commit is contained in:
parent
e3fdf742e7
commit
9384fd07d5
3 changed files with 16 additions and 0 deletions
|
@ -2,6 +2,7 @@ import operations from 'shared/operations';
|
||||||
import messages from 'shared/messages';
|
import messages from 'shared/messages';
|
||||||
import * as scrolls from 'content/scrolls';
|
import * as scrolls from 'content/scrolls';
|
||||||
import * as navigates from 'content/navigates';
|
import * as navigates from 'content/navigates';
|
||||||
|
import * as focuses from 'content/focuses';
|
||||||
import * as urls from 'content/urls';
|
import * as urls from 'content/urls';
|
||||||
import * as consoleFrames from 'content/console-frames';
|
import * as consoleFrames from 'content/console-frames';
|
||||||
import * as addonActions from './addon';
|
import * as addonActions from './addon';
|
||||||
|
@ -57,6 +58,8 @@ const exec = (operation, repeat, settings) => {
|
||||||
return navigates.parent(window);
|
return navigates.parent(window);
|
||||||
case operations.NAVIGATE_ROOT:
|
case operations.NAVIGATE_ROOT:
|
||||||
return navigates.root(window);
|
return navigates.root(window);
|
||||||
|
case operations.FOCUS_INPUT:
|
||||||
|
return focuses.focusInput();
|
||||||
case operations.URLS_YANK:
|
case operations.URLS_YANK:
|
||||||
urls.yank(window);
|
urls.yank(window);
|
||||||
return consoleFrames.postMessage(window.document, {
|
return consoleFrames.postMessage(window.document, {
|
||||||
|
|
10
src/content/focuses.js
Normal file
10
src/content/focuses.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
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');
|
||||||
|
if (target) {
|
||||||
|
target.focus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export { focusInput };
|
|
@ -31,6 +31,9 @@ export default {
|
||||||
NAVIGATE_PARENT: 'navigate.parent',
|
NAVIGATE_PARENT: 'navigate.parent',
|
||||||
NAVIGATE_ROOT: 'navigate.root',
|
NAVIGATE_ROOT: 'navigate.root',
|
||||||
|
|
||||||
|
// Focus
|
||||||
|
FOCUS_INPUT: 'focus.input',
|
||||||
|
|
||||||
// Tabs
|
// Tabs
|
||||||
TAB_CLOSE: 'tabs.close',
|
TAB_CLOSE: 'tabs.close',
|
||||||
TAB_REOPEN: 'tabs.reopen',
|
TAB_REOPEN: 'tabs.reopen',
|
||||||
|
|
Reference in a new issue