Skip to content

Commit ec21408

Browse files
committed
fix(cm-touch-selection): hide stale selection menu and restore menu item actions
1 parent 84bc592 commit ec21408

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/cm/touchSelectionMenu.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,10 @@ class TouchSelectionMenuController {
803803
} else if (text instanceof Node) {
804804
$item.append(text.cloneNode(true));
805805
}
806-
$item.addEventListener("click", (event) => {
806+
let handled = false;
807+
const runAction = (event) => {
808+
if (handled) return;
809+
handled = true;
807810
event.preventDefault();
808811
event.stopPropagation();
809812
this.#handlingMenuAction = true;
@@ -814,7 +817,9 @@ class TouchSelectionMenuController {
814817
this.#hideMenu();
815818
this.#view.focus();
816819
}
817-
});
820+
};
821+
$item.addEventListener("pointerdown", runAction);
822+
$item.addEventListener("click", runAction);
818823
this.$menu.append($item);
819824
});
820825

@@ -901,8 +906,10 @@ class TouchSelectionMenuController {
901906
}
902907

903908
#hideMenu(force = false, clearActive = true) {
904-
if (!force && !this.#menuActive) return;
905-
this.$menu.remove();
909+
if (!force && !this.#menuActive && !this.$menu.isConnected) return;
910+
if (this.$menu.isConnected) {
911+
this.$menu.remove();
912+
}
906913
if (clearActive) {
907914
this.#menuActive = false;
908915
}

0 commit comments

Comments
 (0)