From 45a7840a99717423583da69d3d7da24f5ec6fe58 Mon Sep 17 00:00:00 2001 From: Yueying Lu <lyueying@amazon.de> Date: Wed, 27 Apr 2022 16:52:27 +0200 Subject: [PATCH 1/2] fix cotextmenu cropped --- lib/ace/css/editor.css | 1 + lib/ace/mouse/touch_handler.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/ace/css/editor.css b/lib/ace/css/editor.css index cf65fb83fbb..b6ffa415bd8 100644 --- a/lib/ace/css/editor.css +++ b/lib/ace/css/editor.css @@ -564,6 +564,7 @@ styles.join("\n") padding: 2px; cursor: pointer; overflow: hidden; + display: block; } .ace_mobile-button:hover { background-color: #eee; diff --git a/lib/ace/mouse/touch_handler.js b/lib/ace/mouse/touch_handler.js index 7d02b25b7a1..e1a9e202f1b 100644 --- a/lib/ace/mouse/touch_handler.js +++ b/lib/ace/mouse/touch_handler.js @@ -69,6 +69,17 @@ exports.addTouchListeners = function(el, editor) { ] : ["span"]), contextMenu.firstChild ); + if(isOpen){ + var rect = editor.container.getBoundingClientRect(); + if(contextMenu.offsetTop + contextMenu.offsetHeight > rect.bottom) { + contextMenu.style.top = contextMenu.offsetTop - (contextMenu.offsetHeight - contextMenu.lastChild?.offsetHeight || 0) + "px"; + } + }else{ + var cursor = editor.selection.cursor; + var pagePos = editor.renderer.textToScreenCoordinates(cursor.row, cursor.column); + var rect = editor.container.getBoundingClientRect(); + contextMenu.style.top = pagePos.pageY - rect.top - 3 + "px"; + } }; var handleClick = function(e) { var action = e.target.getAttribute("action"); From 7cc0c2a03f1af4e254f2ff6c80091518063a711e Mon Sep 17 00:00:00 2001 From: Yueying Lu <lyueying@amazon.de> Date: Tue, 10 May 2022 18:35:21 +0200 Subject: [PATCH 2/2] fix contextmenu cropped replace optional chaining --- lib/ace/mouse/touch_handler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mouse/touch_handler.js b/lib/ace/mouse/touch_handler.js index e1a9e202f1b..bc4f17d96cc 100644 --- a/lib/ace/mouse/touch_handler.js +++ b/lib/ace/mouse/touch_handler.js @@ -72,7 +72,7 @@ exports.addTouchListeners = function(el, editor) { if(isOpen){ var rect = editor.container.getBoundingClientRect(); if(contextMenu.offsetTop + contextMenu.offsetHeight > rect.bottom) { - contextMenu.style.top = contextMenu.offsetTop - (contextMenu.offsetHeight - contextMenu.lastChild?.offsetHeight || 0) + "px"; + contextMenu.style.top = contextMenu.offsetTop - contextMenu.offsetHeight + (contextMenu.lastChild ? contextMenu.lastChild.offsetHeight : 0) + "px"; } }else{ var cursor = editor.selection.cursor;