A platform for community discussion. Free, open, simple.
FIX: clear state if selected text is empty (#24102)
Joffrey JAFFEUX619d709d54dd
diff --git a/app/assets/javascripts/discourse/app/components/post-text-selection.gjs b/app/assets/javascripts/discourse/app/components/post-text-selection.gjsindex 4565c0b23a5..a1193e012b2 100644--- a/app/assets/javascripts/discourse/app/components/post-text-selection.gjs+++ b/app/assets/javascripts/discourse/app/components/post-text-selection.gjs@@ -95,6 +95,14 @@ export default class PostTextSelection extends Component {const _selectedText = selectedText();+ const selection = window.getSelection();+ if (selection.isCollapsed || _selectedText === "") {+ if (!this.menuInstance?.expanded) {+ this.args.quoteState.clear();+ }+ return;+ }+// avoid hard loops in quote selection unconditionally// this can happen if you triple click text in firefox// it's also generally unecessary work to go@@ -108,14 +116,6 @@ export default class PostTextSelection extends Component {this.prevSelectedText = _selectedText;- const selection = window.getSelection();- if (selection.isCollapsed) {- if (!this.menuInstance?.expanded) {- this.args.quoteState.clear();- }- return;- }-// ensure we selected content inside 1 post *only*let postId;for (let r = 0; r < selection.rangeCount; r++) {