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

Commit 0343548

Browse files
authored
Don't show broken composer format bar when selection is whitespace (#8673)
1 parent 9a1410e commit 0343548

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/components/views/rooms/BasicMessageComposer.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,11 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
449449
const selection = document.getSelection();
450450
if (this.hasTextSelected && selection.isCollapsed) {
451451
this.hasTextSelected = false;
452-
if (this.formatBarRef.current) {
453-
this.formatBarRef.current.hide();
454-
}
452+
this.formatBarRef.current?.hide();
455453
} else if (!selection.isCollapsed && !isEmpty) {
456454
this.hasTextSelected = true;
457-
if (this.formatBarRef.current && this.state.useMarkdown) {
455+
const range = getRangeForSelection(this.editorRef.current, this.props.model, selection);
456+
if (this.formatBarRef.current && this.state.useMarkdown && !!range.text.trim()) {
458457
const selectionRect = selection.getRangeAt(0).getBoundingClientRect();
459458
this.formatBarRef.current.showAt(selectionRect);
460459
}

0 commit comments

Comments
 (0)