WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 6afb048

Browse files
authored
fix tooltip position when editor is placed in new stacking context (#5853)
* fix tooltip position when editor is placed in new stacking context * pin typescript version until we update types
1 parent 29a5557 commit 6afb048

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

demo/kitchen-sink/demo.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,15 @@ function openTestDialog(animateHeight) {
597597
window.dialogEditor.destroy();
598598
var editor = ace.edit(null, {
599599
value: "test editor",
600-
mode: "ace/mode/javascript"
600+
mode: "ace/mode/javascript",
601+
enableBasicAutocompletion: true
601602
});
602603
window.dialogEditor = editor;
603604

605+
editor.completer.parentNode = editor.container;
606+
if (window.languageProvider)
607+
window.languageProvider.registerEditor(editor);
608+
604609
var dialog = dom.buildDom(["div", {
605610
style: "transition: all 1s; position: fixed; z-index: 100000;"
606611
+ "background: darkblue; border: solid 1px black; display: flex; flex-direction: column"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"eslint": "^8.20.0",
2222
"istanbul": "^0.4.5",
2323
"standard-version": "^9.3.2",
24-
"typescript": "^5.6.3"
24+
"typescript": "5.8.3"
2525
},
2626
"mappings": {
2727
"ace": "."

src/autocomplete/popup.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,24 +370,27 @@ class AcePopup {
370370
renderer.$maxPixelHeight = null;
371371
}
372372

373+
el.style.display = "";
374+
var rootRect = el.offsetParent && el.offsetParent.getBoundingClientRect();
375+
373376

374377
if (anchor === "top") {
375378
el.style.top = "";
376-
el.style.bottom = (screenHeight + scrollBarSize - dims.bottom) + "px";
379+
el.style.bottom = (screenHeight + scrollBarSize - dims.bottom)
380+
- (rootRect ? screenHeight + scrollBarSize - rootRect.bottom : 0)+ "px";
377381
popup.isTopdown = false;
378382
} else {
379-
el.style.top = dims.top + "px";
383+
el.style.top = (dims.top - (rootRect ? rootRect.top : 0)) + "px";
380384
el.style.bottom = "";
381385
popup.isTopdown = true;
382386
}
383387

384-
el.style.display = "";
385388

386389
var left = pos.left;
387390
if (left + el.offsetWidth > screenWidth)
388391
left = screenWidth - el.offsetWidth;
389392

390-
el.style.left = left + "px";
393+
el.style.left = (left - (rootRect ? rootRect.left : 0)) + "px";
391394
el.style.right = "";
392395

393396
if (!popup.isOpen) {
@@ -469,7 +472,7 @@ dom.importCssString(`
469472
width: 300px;
470473
z-index: 200000;
471474
border: 1px lightgray solid;
472-
position: fixed;
475+
position: absolute;
473476
box-shadow: 2px 3px 5px rgba(0,0,0,.2);
474477
line-height: 1.4;
475478
background: #fefefe;

src/css/editor-css.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ module.exports = `
460460
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
461461
color: black;
462462
padding: 3px 4px;
463-
position: fixed;
463+
position: absolute;
464464
z-index: 999999;
465465
box-sizing: border-box;
466466
cursor: default;

src/tooltip.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ class Tooltip {
5656
* @param {Number} y
5757
**/
5858
setPosition(x, y) {
59-
this.getElement().style.left = x + "px";
60-
this.getElement().style.top = y + "px";
59+
var el = this.getElement();
60+
var rootRect = el.offsetParent && el.offsetParent.getBoundingClientRect();
61+
el.style.left = x - (rootRect ? rootRect.left : 0) + "px";
62+
el.style.top = y - (rootRect ? rootRect.top : 0) + "px";
6163
}
6264

6365
/**

0 commit comments

Comments
 (0)