Context Menu doesn't work when container has transform: translate
See original GitHub issueDetails
- Browser and browser version: Chrome 71.0.3578.98
- OS version: Windows 10 & MacOS Mojave
- xterm.js version: v3.10.1
Steps to reproduce
- Visit https://o9xjjwo47y.codesandbox.io/
- Right click anywhere inside the black xterm terminal
- See that it opens up the canvas context menu instead of the textarea context menu
Related: #1810
Example code snippet
Also here: https://codesandbox.io/s/o9xjjwo47y
import React from "react";
import ReactDOM from "react-dom";
import Draggable from "react-draggable";
import { Terminal } from "xterm";
import * as fit from "xterm/lib/addons/fit/fit";
import "xterm/dist/xterm.css";
import "./styles.css";
Terminal.applyAddon(fit);
class App extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
x: 0,
y: 0
};
}
componentDidMount() {
const term = new Terminal();
term.open(document.getElementById("xterm"));
term.fit();
term.write("Hello from \x1B[1;3;31mxterm.js\x1B[0m $ ");
}
render() {
const { x, y } = this.state;
return (
<div className="App">
<h1>Xterm.js Right Click Bug Example</h1>
<p>
Right click anywhere inside the black terminal and you will see that
the canvas context menu shows up instead of the textarea context menu
</p>
<p>
If you open dev-tools and remove the "transform: translate" style from
the parent container div, then the correct context menu shows up
</p>
<Draggable
position={{ x, y }}
onDrag={(e, data) => this.setState({ x: data.x, y: data.y })}
>
<div
id="parent-container"
style={{
width: 500,
height: 500,
padding: "1em",
background: "#333"
}}
>
<div id="xterm" />
</div>
</Draggable>
</div>
);
}
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Custom Context Menu splits on columns - css - Stack Overflow
Here's the code, I tested it with Tampermonkey and it works fine. ... contextMenu li { border-bottom: 1px solid gray; }'); GM_addStyle('.
Read more >translate() - CSS: Cascading Style Sheets - MDN Web Docs
This transformation is characterized by a two-dimensional vector. Its coordinates define how much the element moves in each direction. Syntax.
Read more >Position fixed doesn't work with transform property - SitePoint
I'm the building offscreen navigation, and for pushing it I use transform: translate(x,y); . It works, all is sliding fine, but it should...
Read more >transform - CSS-Tricks
The transform property allows you to visually manipulate an element by skewing, rotating, translating, or scaling:
Read more >Topic: Transform, transition not working / sciter
Transform, transition not working ; E:animating, Element, at the moment, is animating e.g. expanding/collapsing, STATE_ANIMATING ; E:popup ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@zxlin ev.clientX and ev.clientY are probably relative to the wrong element, that would need to be tweaked to work in both cases.
@mofux We have xterm inside a draggable container to allow the user to lay out their work space to their personal preference. That’s simply the lib’s way of implementing draggable.
One thing of note here is that the
transform
style doesn’t need to be on the parent element of xterm to cause this issue, if any of xterm’s ancestor elements has thetransform
style, this bug occurs.