diff --git a/src/components/views/rooms/BasicMessageComposer.tsx b/src/components/views/rooms/BasicMessageComposer.tsx index 335f757190..fd3f5eed3d 100644 --- a/src/components/views/rooms/BasicMessageComposer.tsx +++ b/src/components/views/rooms/BasicMessageComposer.tsx @@ -449,12 +449,11 @@ export default class BasicMessageEditor extends React.Component 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); }