jh-changes
Shin'ya Ueoka 7 years ago
parent ccc81312a1
commit a57cdbd5b5
  1. 6
      src/content/components/common/follow.js
  2. 10
      src/content/components/common/input.js
  3. 8
      src/shared/utils/dom.js

@ -1,5 +1,6 @@
import messages from 'shared/messages';
import Hint from './hint';
import * as dom from 'shared/utils/dom';
const TARGET_SELECTOR = [
'a', 'button', 'input', 'textarea',
@ -136,8 +137,9 @@ export default class Follow {
case 'button':
return element.click();
default:
// it may contenteditable
return element.focus();
if (dom.isContentEditable(element)) {
return element.focus();
}
}
}

@ -1,3 +1,5 @@
import * as dom from 'shared/utils/dom';
const modifierdKeyName = (name) => {
if (name.length === 1) {
return name.toUpperCase();
@ -78,12 +80,12 @@ export default class InputComponent {
}
fromInput(e) {
if (!e.target) {
return false;
}
return e.target instanceof HTMLInputElement ||
e.target instanceof HTMLTextAreaElement ||
e.target instanceof HTMLSelectElement ||
e.target instanceof HTMLElement &&
e.target.hasAttribute('contenteditable') && (
e.target.getAttribute('contenteditable').toLowerCase() === 'true' ||
e.target.getAttribute('contenteditable').toLowerCase() === '');
dom.isContentEditable(e.target);
}
}

@ -0,0 +1,8 @@
const isContentEditable = (element) => {
return element.hasAttribute('contenteditable') && (
element.getAttribute('contenteditable').toLowerCase() === 'true' ||
element.getAttribute('contenteditable').toLowerCase() === ''
);
};
export { isContentEditable };