Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix: clicking bottom of page doesn't always unselect current selection (#3862)

Wolf Mermelsteind696b03dc38c
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/core/FocusClickTarget.tsx b/js/app/packages/core/component/LexicalMarkdown/component/core/FocusClickTarget.tsx
index c896e48380..686c6b0867 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/core/FocusClickTarget.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/core/FocusClickTarget.tsx
@@ -17,7 +17,16 @@ export function FocusClickTarget(
return (
<div
onMouseDown={(e: MouseEvent) => {
- e.preventDefault(); // this div should not take focus.
+ // don't prevent default when there's an active selection
+ // since the expected behavior is that it unselects
+ let hasActiveSelection = false;
+ local.editor.getEditorState().read(() => {
+ const sel = $getSelection();
+ hasActiveSelection = $isRangeSelection(sel) && !sel.isCollapsed();
+ });
+ if (!hasActiveSelection) {
+ e.preventDefault();
+ }
}}
classList={{
'invisible-focus-target': true,