diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index 6919a304c2..b71aaa6a42 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -33,7 +33,6 @@ import PlainWithPillsSerializer from "../../../autocomplete/PlainWithPillsSerial // Entity} from 'draft-js'; import classNames from 'classnames'; -import escape from 'lodash/escape'; import Promise from 'bluebird'; import MatrixClientPeg from '../../../MatrixClientPeg'; @@ -507,6 +506,15 @@ export default class MessageComposerInput extends React.Component { } }); + // work around weird bug where inserting emoji via the macOS + // emoji picker can leave the selection stuck in the emoji's + // child text. This seems to happen due to selection getting + // moved in the normalisation phase after calculating these changes + if (editorState.document.getParent(editorState.anchorKey).type === 'emoji') { + change = change.collapseToStartOfNextText(); + editorState = change.value; + } + /* const currentBlock = editorState.getSelection().getStartKey(); const currentSelection = editorState.getSelection();