Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Remove all text when cutting in the composer
Browse files Browse the repository at this point in the history
The previous function did in fact remove the elements, but left the model thinking there was a zero-length string. This approach deletes the text from the model and the DOM, resulting in the placeholder being shown when cutting all the text.

Part of element-hq/element-web#11378
  • Loading branch information
turt2live committed Jan 16, 2020
1 parent cad9562 commit be3ef2b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/views/rooms/BasicMessageComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ export default class BasicMessageEditor extends React.Component {
const selectedParts = range.parts.map(p => p.serialize());
event.clipboardData.setData("application/x-riot-composer", JSON.stringify(selectedParts));
if (type === "cut") {
selection.deleteFromDocument();
range.replace([]);
// Remove the text from the composer
const {caret} = getCaretOffsetAndText(this._editorRef, selection);
this.props.model.update("", event.inputType, caret);
}
event.preventDefault();
}
Expand Down

0 comments on commit be3ef2b

Please sign in to comment.