@@ -360,6 +360,9 @@ class TouchSelectionMenuController {
360360 ) {
361361 return ;
362362 }
363+ if ( this . #isIgnoredPointerTarget( target ) ) {
364+ return ;
365+ }
363366 if (
364367 event . type === "touchstart" &&
365368 target instanceof Node &&
@@ -373,6 +376,7 @@ class TouchSelectionMenuController {
373376
374377 #onContextMenu = ( event ) => {
375378 if ( ! this . #enabled) return ;
379+ if ( this . #isIgnoredPointerTarget( event . target ) ) return ;
376380 event . preventDefault ( ) ;
377381 event . stopPropagation ( ) ;
378382
@@ -397,6 +401,7 @@ class TouchSelectionMenuController {
397401 #onMouseDown = ( event ) => {
398402 if ( ! this . #enabled) return ;
399403 if ( event . button !== 0 ) return ;
404+ if ( this . #isIgnoredPointerTarget( event . target ) ) return ;
400405 this . #mouseSelecting = true ;
401406 } ;
402407
@@ -417,6 +422,11 @@ class TouchSelectionMenuController {
417422
418423 #onTouchStart = ( event ) => {
419424 if ( ! this . #enabled || event . touches . length !== 1 ) return ;
425+ if ( this . #isIgnoredPointerTarget( event . target ) ) {
426+ this . #touchSession = null ;
427+ this . #clearLongPress( ) ;
428+ return ;
429+ }
420430 const touch = event . touches [ 0 ] ;
421431 const { clientX, clientY } = touch ;
422432 const now = performance . now ( ) ;
@@ -1133,6 +1143,25 @@ class TouchSelectionMenuController {
11331143 return ! ! this . #view. state ?. readOnly ;
11341144 }
11351145
1146+ #isIgnoredPointerTarget( target ) {
1147+ let element = null ;
1148+ if ( target instanceof Element ) {
1149+ element = target ;
1150+ } else if ( target instanceof Node ) {
1151+ element = target . parentElement ;
1152+ }
1153+ if ( ! element ) return false ;
1154+ if ( element . closest ( ".cm-tooltip, .cm-panel" ) ) return true ;
1155+ if (
1156+ element . closest (
1157+ "input, textarea, select, button, a, [contenteditable], [role=\"button\"]" ,
1158+ )
1159+ ) {
1160+ return true ;
1161+ }
1162+ return false ;
1163+ }
1164+
11361165 #hasSelection( ) {
11371166 const selection = this . #view. state . selection . main ;
11381167 return selection . from !== selection . to ;
0 commit comments