Skip to content

Commit dfeafe0

Browse files
committed
Don't use position: fixed in context-menu hack
It doesn't work inside of a transformed container, even for zero transforms (which some components seem to love putting on root elements, for whichever reason) Closes codemirror#3238
1 parent 4ffe46b commit dfeafe0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/codemirror.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,10 +1482,11 @@
14821482
if (reset && cm.doc.sel.contains(pos) == -1)
14831483
operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
14841484

1485-
var oldCSS = te.style.cssText;
1486-
input.wrapper.style.position = "absolute";
1487-
te.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
1488-
"px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " +
1485+
var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText;
1486+
input.wrapper.style.cssText = "position: absolute"
1487+
var wrapperBox = input.wrapper.getBoundingClientRect()
1488+
te.style.cssText = "position: absolute; width: 30px; height: 30px; top: " + (e.clientY - wrapperBox.top - 5) +
1489+
"px; left: " + (e.clientX - wrapperBox.left - 5) + "px; z-index: 1000; background: " +
14891490
(ie ? "rgba(255, 255, 255, .05)" : "transparent") +
14901491
"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
14911492
if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712)
@@ -1516,7 +1517,7 @@
15161517
}
15171518
function rehide() {
15181519
input.contextMenuPending = false;
1519-
input.wrapper.style.position = "relative";
1520+
input.wrapper.style.cssText = oldWrapperCSS
15201521
te.style.cssText = oldCSS;
15211522
if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
15221523

0 commit comments

Comments
 (0)