Skip to content

Commit

Permalink
render popover to other side on rtl
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Apr 11, 2018
1 parent eb12969 commit 190cd4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
32 changes: 8 additions & 24 deletions packages/rocketchat-ui-sidenav/client/sidebarHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,9 @@ const toolbarButtons = (user) => {
]
}
],
mousePosition: () => ({
x: e.currentTarget.getBoundingClientRect().left,
y: e.currentTarget.getBoundingClientRect().bottom + 50
}),
currentTarget: e.currentTarget,
customCSSProperties: () => ({
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`,
left: `${ e.currentTarget.getBoundingClientRect().left - 10 }px`
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`
})
};

Expand All @@ -125,13 +121,9 @@ const toolbarButtons = (user) => {
const options = [];
const config = {
template: 'sortlist',
mousePosition: () => ({
x: e.currentTarget.getBoundingClientRect().left,
y: e.currentTarget.getBoundingClientRect().bottom + 50
}),
currentTarget: e.currentTarget,
customCSSProperties: () => ({
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`,
left: `${ e.currentTarget.getBoundingClientRect().left - 10 }px`
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`
}),
data: {
// value: instance.form[key].get(),
Expand Down Expand Up @@ -209,13 +201,9 @@ const toolbarButtons = (user) => {
]
}
],
mousePosition: () => ({
x: e.currentTarget.getBoundingClientRect().left,
y: e.currentTarget.getBoundingClientRect().bottom + 50
}),
currentTarget: e.currentTarget,
customCSSProperties: () => ({
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`,
left: `${ e.currentTarget.getBoundingClientRect().left - 10 }px`
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`
})
};

Expand Down Expand Up @@ -323,13 +311,9 @@ Template.sidebarHeader.events({
]
}
],
mousePosition: () => ({
x: e.currentTarget.getBoundingClientRect().left,
y: e.currentTarget.getBoundingClientRect().bottom + 50
}),
currentTarget: e.currentTarget,
customCSSProperties: () => ({
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`,
left: `${ e.currentTarget.getBoundingClientRect().left - 10 }px`
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`
})
};

Expand Down
5 changes: 4 additions & 1 deletion packages/rocketchat-ui/client/views/app/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ Template.popover.onRendered(function() {
const position = _.throttle(() => {
const position = typeof this.data.position === 'function' ? this.data.position() : this.data.position;
const customCSSProperties = typeof this.data.customCSSProperties === 'function' ? this.data.customCSSProperties() : this.data.customCSSProperties;
const mousePosition = typeof this.data.mousePosition === 'function' ? this.data.mousePosition() : this.data.mousePosition;
const mousePosition = typeof this.data.mousePosition === 'function' ? this.data.mousePosition() : this.data.mousePosition || {
x: this.data.currentTarget.getBoundingClientRect()[isRtl() ? 'right': 'left'],
y: this.data.currentTarget.getBoundingClientRect().bottom + 50
};
if (position) {
popoverContent.style.top = `${ position.top }px`;
popoverContent.style.left = `${ position.left }px`;
Expand Down

0 comments on commit 190cd4b

Please sign in to comment.