diff --git a/src/client/automation/playback/type/type-text.js b/src/client/automation/playback/type/type-text.js index 43b7699ea86..c008d07ce6b 100644 --- a/src/client/automation/playback/type/type-text.js +++ b/src/client/automation/playback/type/type-text.js @@ -82,21 +82,6 @@ function _excludeInvisibleSymbolsFromSelection (selection) { return selection; } -var getSelectionInfo = (selection, text) => { - const startNode = selection.startPos.node; - const startOffset = selection.startPos.offset; - const endOffset = selection.endPos.offset; - const nodeValue = startNode.nodeValue; - const selectPosition = { node: startNode, offset: startOffset + text.length }; - - return { - startOffset, - endOffset, - nodeValue, - selectPosition - }; -}; - function _typeTextToContentEditable (element, text) { var currentSelection = _getSelectionInElement(element); var startNode = currentSelection.startPos.node; @@ -152,27 +137,24 @@ function _typeTextToContentEditable (element, text) { return; } - currentSelection = _excludeInvisibleSymbolsFromSelection(currentSelection); + currentSelection = _excludeInvisibleSymbolsFromSelection(currentSelection); startNode = currentSelection.startPos.node; - var prevStartNode = startNode; beforeContentChanged(); if (needRaiseInput) { - - // NOTE: selection could be changed on textInput event - const changedSelection = _excludeInvisibleSymbolsFromSelection(_getSelectionInElement(element)); + const selectionChangedOnTextInput = !domUtils.isTheSameNode(currentSelection.startPos.node, changedSelection.startPos.node); - startNode = changedSelection.startPos.node; - - const selectionChanged = !domUtils.isTheSameNode(prevStartNode, startNode); - - - if (selectionChanged) + if (selectionChangedOnTextInput) { currentSelection = changedSelection; + startNode = currentSelection.startPos.node; + } - const { startOffset, endOffset, nodeValue, selectPosition } = getSelectionInfo(currentSelection, text); + const startOffset = currentSelection.startPos.offset; + const endOffset = currentSelection.endPos.offset; + const nodeValue = startNode.nodeValue; + const selectPosition = { node: startNode, offset: startOffset + text.length }; startNode.nodeValue = nodeValue.substring(0, startOffset) + text + nodeValue.substring(endOffset, nodeValue.length); diff --git a/test/functional/fixtures/regression/gh-1956/pages/test.html b/test/functional/fixtures/regression/gh-1956/pages/test.html index 2940b575eb9..c4de69f2c9c 100644 --- a/test/functional/fixtures/regression/gh-1956/pages/test.html +++ b/test/functional/fixtures/regression/gh-1956/pages/test.html @@ -2,7 +2,6 @@ Edit test