fix bug where selection breaks after inserting emoji

This commit is contained in:
Matthew Hodgson 2018-05-23 00:41:46 +01:00
parent 11cea61661
commit cace5e8bfc

View file

@ -33,7 +33,6 @@ import PlainWithPillsSerializer from "../../../autocomplete/PlainWithPillsSerial
// Entity} from 'draft-js'; // Entity} from 'draft-js';
import classNames from 'classnames'; import classNames from 'classnames';
import escape from 'lodash/escape';
import Promise from 'bluebird'; import Promise from 'bluebird';
import MatrixClientPeg from '../../../MatrixClientPeg'; 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 currentBlock = editorState.getSelection().getStartKey();
const currentSelection = editorState.getSelection(); const currentSelection = editorState.getSelection();