diff --git a/src/client/core/utils/content-editable.js b/src/client/core/utils/content-editable.js index bb639ead888..cf9c64af693 100644 --- a/src/client/core/utils/content-editable.js +++ b/src/client/core/utils/content-editable.js @@ -1,5 +1,6 @@ import * as domUtils from './dom'; import * as arrayUtils from './array'; +import { isElementVisible } from './position'; //nodes utils @@ -397,6 +398,9 @@ export function calculateNodeAndOffsetByPosition (el, offset) { } } else if (domUtils.isElementNode(target)) { + if (!isElementVisible(target)) + return point; + if (point.offset === 0 && !getContentEditableValue(target).length) { point.node = target; return point; diff --git a/src/client/core/utils/style.js b/src/client/core/utils/style.js index 7e9ca57fa89..5308295903a 100644 --- a/src/client/core/utils/style.js +++ b/src/client/core/utils/style.js @@ -135,22 +135,6 @@ export function hasDimensions (el) { return el && !(el.offsetHeight <= 0 && el.offsetWidth <= 0); } -export function isElementHidden (el) { - //NOTE: it's like jquery ':hidden' selector - if (get(el, 'display') === 'none' || !hasDimensions(el) || el.type && el.type === 'hidden') - return true; - - var elements = domUtils.findDocument(el).querySelectorAll('*'); - var hiddenElements = []; - - for (var i = 0; i < elements.length; i++) { - if (get(elements[i], 'display') === 'none' || !hasDimensions(elements[i])) - hiddenElements.push(elements[i]); - } - - return domUtils.containsElement(hiddenElements, el); -} - export function set (el, style, value) { if (typeof style === 'string') styleUtils.set(el, style, value); diff --git a/test/functional/fixtures/regression/gh-2205/pages/index.html b/test/functional/fixtures/regression/gh-2205/pages/index.html new file mode 100644 index 00000000000..fee2322c6f9 --- /dev/null +++ b/test/functional/fixtures/regression/gh-2205/pages/index.html @@ -0,0 +1,85 @@ + + + + + Title + + + + +

Has inner div with contentEditable=false

+ +
+
+
+ + + + \ No newline at end of file diff --git a/test/functional/fixtures/regression/gh-2205/test.js b/test/functional/fixtures/regression/gh-2205/test.js new file mode 100644 index 00000000000..e947b52eb4e --- /dev/null +++ b/test/functional/fixtures/regression/gh-2205/test.js @@ -0,0 +1,5 @@ +describe('[Regression](GH-2205)', function () { + it('Should type in div if it has an invisible child with contententeditable=false', function () { + return runTests('testcafe-fixtures/index.js'); + }); +}); diff --git a/test/functional/fixtures/regression/gh-2205/testcafe-fixtures/index.js b/test/functional/fixtures/regression/gh-2205/testcafe-fixtures/index.js new file mode 100644 index 00000000000..a59926802da --- /dev/null +++ b/test/functional/fixtures/regression/gh-2205/testcafe-fixtures/index.js @@ -0,0 +1,13 @@ +import { Selector } from 'testcafe'; + +fixture `GH-2205 - Should type in div if it has an invisible child with contententeditable=false` + .page `http://localhost:3000/fixtures/regression/gh-2205/pages/index.html`; + +test(`Click on div with placeholder`, async t => { + const editor = Selector('#editor'); + + await t + .click(editor) + .typeText(editor, 'Hello') + .expect(editor.innerText).contains('Hello'); +});