1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-10 09:22:25 +03:00

Don't show broken composer format bar when selection is whitespace (#8673)

This commit is contained in:
Michael Telatynski
2022-05-24 09:08:46 +01:00
committed by GitHub
parent 9a1410e34c
commit 0343548dbe

View File

@@ -449,12 +449,11 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
const selection = document.getSelection();
if (this.hasTextSelected && selection.isCollapsed) {
this.hasTextSelected = false;
if (this.formatBarRef.current) {
this.formatBarRef.current.hide();
}
this.formatBarRef.current?.hide();
} else if (!selection.isCollapsed && !isEmpty) {
this.hasTextSelected = true;
if (this.formatBarRef.current && this.state.useMarkdown) {
const range = getRangeForSelection(this.editorRef.current, this.props.model, selection);
if (this.formatBarRef.current && this.state.useMarkdown && !!range.text.trim()) {
const selectionRect = selection.getRangeAt(0).getBoundingClientRect();
this.formatBarRef.current.showAt(selectionRect);
}