Skip to content

Commit 4b645bc

Browse files
committed
Make context menus point the right way
1 parent 1f3a6e4 commit 4b645bc

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

src/ContextualMenu.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,25 @@ module.exports = {
4949

5050
var position = {
5151
top: props.top - 20,
52-
right: props.right + 8,
5352
};
5453

54+
var chevron = null;
55+
if (props.left) {
56+
chevron = <img className="mx_ContextualMenu_chevron_left" src="img/chevron-left.png" width="9" height="16" />
57+
position.left = props.left + 8;
58+
} else {
59+
chevron = <img className="mx_ContextualMenu_chevron_right" src="img/chevron-right.png" width="9" height="16" />
60+
position.right = props.right + 8;
61+
}
62+
63+
var className = 'mx_ContextualMenu_wrapper';
64+
5565
// FIXME: If a menu uses getDefaultProps it clobbers the onFinished
5666
// property set here so you can't close the menu from a button click!
5767
var menu = (
58-
<div className="mx_ContextualMenu_wrapper">
68+
<div className={className}>
5969
<div className="mx_ContextualMenu" style={position}>
60-
<img className="mx_ContextualMenu_chevron" src="img/chevron-right.png" width="9" height="16" />
70+
{chevron}
6171
<Element {...props} onFinished={closeMenu}/>
6272
</div>
6373
<div className="mx_ContextualMenu_background" onClick={closeMenu}></div>

src/skins/vector/css/common.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,20 @@ a:visited {
6767
padding: 6px;
6868
}
6969

70-
.mx_ContextualMenu_chevron {
70+
.mx_ContextualMenu_chevron_right {
7171
padding: 12px;
7272
position: absolute;
7373
right: -21px;
7474
top: 0px;
7575
}
7676

77+
.mx_ContextualMenu_chevron_left {
78+
padding: 12px;
79+
position: absolute;
80+
left: -21px;
81+
top: 0px;
82+
}
83+
7784
.mx_ContextualMenu_field {
7885
padding: 3px 6px 3px 6px;
7986
cursor: pointer;

src/skins/vector/views/molecules/EventTile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ module.exports = React.createClass({
5050
onEditClicked: function(e) {
5151
var MessageContextMenu = sdk.getComponent('molecules.MessageContextMenu');
5252
var buttonRect = e.target.getBoundingClientRect()
53-
var x = window.innerWidth - buttonRect.left;
53+
var x = buttonRect.right;
5454
var y = buttonRect.top + (e.target.height / 2);
5555
var self = this;
5656
ContextualMenu.createMenu(MessageContextMenu, {
5757
mxEvent: this.props.mxEvent,
58-
right: x,
58+
left: x,
5959
top: y,
6060
onFinished: function() {
6161
self.setState({menu: false});

0 commit comments

Comments
 (0)