Skip to content

A platform for community discussion. Free, open, simple.

FIX: preserve text selection inside form fields in cooked content (#40985)

David Taylorc9d4e272a595
diff --git a/frontend/discourse/app/components/post-text-selection.gjs b/frontend/discourse/app/components/post-text-selection.gjs
index 43169d271bd..092c9d703e0 100644
--- a/frontend/discourse/app/components/post-text-selection.gjs
+++ b/frontend/discourse/app/components/post-text-selection.gjs
@@ -250,7 +250,9 @@ export default class PostTextSelection extends Component {
return; // we changed the range here, so we want to go through the selection change handler again
}
- if (!window.getSelection().toString().trim().length) {
+ const selection = window.getSelection();
+
+ if (selection.isCollapsed || !selection.toString().trim().length) {
return;
}