mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 17:02:45 +08:00
FIX: correctly clear the quote state (#23705)
Prior to this fix clicking outside text and reseting the selection wouldn't clear the quote state, which would cause a click on "reply" or "create" to start the composer with the quote state. This commit attempts to simplify this behaviour by not mutating quote state while the menu is opened. The quote state will now only be cleared when the menu is closed. No tests have ever been written for this complex and subtle behavior (both `mousedown` and `selectionchange` events can trigger the final `selectionChanged` codepath which prevents us to for example stop the event when clicking quote as it will still change the selection even if we can prevent the `mousedown`. Ideally a huge part of this code should be rewritten to be easier to test, this commit only attempt to fix a regression introduced when using FloatKit to position the menu.
This commit is contained in:
parent
34cc87db40
commit
a441f07908
|
@ -102,6 +102,9 @@ export default class PostTextSelection extends Component {
|
||||||
const selection = window.getSelection();
|
const selection = window.getSelection();
|
||||||
|
|
||||||
if (selection.isCollapsed) {
|
if (selection.isCollapsed) {
|
||||||
|
if (!this.menuInstance?.expanded) {
|
||||||
|
this.args.quoteState.clear();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user