Skip to content

Commit

Permalink
Don't use position: fixed in context-menu hack
Browse files Browse the repository at this point in the history
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 #3238
  • Loading branch information
marijnh committed Feb 2, 2016
1 parent 4ffe46b commit dfeafe0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -1482,10 +1482,11 @@
if (reset && cm.doc.sel.contains(pos) == -1)
operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);

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

Expand Down

0 comments on commit dfeafe0

Please sign in to comment.