Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent mistakenly opening a search box in some situations #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions src/core/content.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
"use strict";

const excludedTriggerKeys = [
'Shift',
'Alt',
'Control',
'Meta',
'ContextMenu',
'OS',
'AltGraph',
'Escape',
' ',
'Dead',
'Enter'
];


let triggerKey = "";

Expand Down Expand Up @@ -56,7 +42,7 @@ function handleKeydown (event) {
}

// check if is character key
else if (event.code !== event.key && !excludedTriggerKeys.includes(event.key)) {
else if (!/\w\w/.test(event.key) && event.key !== " ") {
pressedKey = event.key;
}

Expand Down Expand Up @@ -86,9 +72,10 @@ function isEditable (element) {
const editableInputTypes = ["text", "textarea", "password", "email", "number", "tel", "url", "search"];

return (
document.designMode === "on" ||
element.isContentEditable ||
(
(element.tagName === 'INPUT' || element.tagName === 'TEXTAREA' || element.tagName === 'SELECT')
(element.localName === "input" || element.localName === "textarea" || element.localName === "select")
&& (!element.type || editableInputTypes.includes(element.type))
&& !element.disabled
&& !element.readOnly
Expand Down