Skip to content

Commit 4397120

Browse files
authored
[ENG-565] node menu stealing click focus (#281)
* allow cmd c + cmd x events * another fix for eng-591
1 parent 3963d91 commit 4397120

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

apps/roam/src/components/DiscourseNodeMenu.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ const NodeMenu = ({
100100

101101
const keydownListener = useCallback(
102102
(e: KeyboardEvent) => {
103+
if (e.metaKey || e.ctrlKey || e.shiftKey) return;
104+
103105
if (e.key === "ArrowDown") {
104106
const index = Number(
105107
menuRef.current?.getAttribute("data-active-index"),

apps/roam/src/utils/initializeObserversAndListeners.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,10 @@ export const initObservers = async ({
257257

258258
const selection = window.getSelection();
259259

260-
if (!selection || selection.rangeCount === 0) return;
260+
if (!selection || selection.rangeCount === 0 || !selection.focusNode) {
261+
removeTextSelectionPopup();
262+
return;
263+
}
261264

262265
const selectedText = selection.toString().trim();
263266

apps/roam/src/utils/renderTextSelectionPopup.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ export const renderTextSelectionPopup = ({
6565
};
6666

6767
export const removeTextSelectionPopup = () => {
68-
if (currentPopupContainer) {
69-
ReactDOM.unmountComponentAtNode(currentPopupContainer);
70-
currentPopupContainer.remove();
71-
currentPopupContainer = null;
68+
const container = document.getElementById("discourse-text-selection-popup");
69+
if (container) {
70+
ReactDOM.unmountComponentAtNode(container);
71+
container.remove();
7272
}
7373
};

0 commit comments

Comments
 (0)