mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: clear state if selected text is empty (#24102)
This would cause a loop and some very fast flashing of the selection in safari when scrolling the selection until the bottom of the page.
This commit is contained in:
parent
e231ed2153
commit
619d709d54
@ -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++) {
|
||||
|
Loading…
Reference in New Issue
Block a user