Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Wrong positioning of popover when using RTL languages #10428

Merged
merged 7 commits into from
Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions packages/rocketchat-emoji/client/lib/EmojiPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import _ from 'underscore';

RocketChat.EmojiPicker = {
width: 390,
height: 238,
width: 365,
height: 290,
initiated: false,
input: null,
source: null,
Expand Down Expand Up @@ -54,27 +54,23 @@ RocketChat.EmojiPicker = {
return this.recent;
},
setPosition() {
const windowHeight = window.innerHeight;
const windowBorder = 10;
const sourcePos = $(this.source).offset();
const left = sourcePos.left;
const top = sourcePos.top - this.height - 60;
const cssProperties = {
top,
left
};

if (top < 0) {
cssProperties.top = 10;
const top = sourcePos.top;
const cssProperties = {top, left};

if (top + this.height >= windowHeight) {
cssProperties.top = windowHeight - this.height - windowBorder;
}

if (left < 35) {
cssProperties.left = 0;
} else {
const windowSize = $(window).width();
const pickerWidth = $('.emoji-picker').outerWidth();
if (left < windowBorder) {
cssProperties.left = windowBorder;
}

if (left + pickerWidth > windowSize) {
cssProperties.left = left - pickerWidth;
}
if (left + this.width >= window.innerWidth) {
cssProperties.left = left - this.width - windowBorder;
}

return $('.emoji-picker').css(cssProperties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,21 +309,15 @@ Template.pushNotificationsFlexTab.events({
const config = {
popoverClass: 'notifications-preferences',
template: 'pushNotificationsPopover',
mousePosition: () => ({
x: e.currentTarget.getBoundingClientRect().left,
y: e.currentTarget.getBoundingClientRect().bottom + 50
}),
customCSSProperties: () => ({
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`,
left: `${ e.currentTarget.getBoundingClientRect().left - 10 }px`
}),
data: {
change : (value) => {
return instance.form[key].set(key === 'desktopNotificationDuration' ? parseInt(value) : value);
},
value: instance.form[key].get(),
options
}
},
currentTarget: e.currentTarget,
offsetVertical: e.currentTarget.clientHeight + 10
};
popover.open(config);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.sidebar__header {
position: relative;

display: flex;

margin: 0 -10px;
Expand Down Expand Up @@ -31,11 +32,11 @@
width: var(--sidebar-account-status-bullet-size);
height: var(--sidebar-account-status-bullet-size);

border-width: 2px;
pointer-events: none;

border-width: 2px;
border-style: solid;
border-color: var(--sidebar-background);

border-radius: var(--sidebar-account-status-bullet-radius);

&--online {
Expand Down Expand Up @@ -77,9 +78,11 @@
&-search {
position: absolute;
right: calc(10px + var(--sidebar-default-padding));
width: 200px;

display: none;

width: 200px;

& .rc-input__element {
background-color: var(--sidebar-background);
}
Expand Down
15 changes: 4 additions & 11 deletions packages/rocketchat-ui-flextab/client/flexTabBar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals popover, isRtl */
/* globals popover */
import _ from 'underscore';

const commonHelpers = {
Expand Down Expand Up @@ -149,22 +149,15 @@ Template.RoomsActionTab.events({
columns[0] = {groups};
const config = {
columns,
// template: 'RoomsActionMore',
popoverClass: 'message-box',
mousePosition: () => ({
x: e.currentTarget.getBoundingClientRect().right + 10,
y: e.currentTarget.getBoundingClientRect().bottom + 100
}),
customCSSProperties: () => ({
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`,
left: isRtl() ? `${ e.currentTarget.getBoundingClientRect().left - 10 }px` : undefined
}),
data: {
rid: this._id,
buttons: instance.small.get() ? buttons : buttons.slice(4),
tabBar: instance.tabBar
},
activeElement: e.currentTarget
currentTarget: e.currentTarget,
offsetHorizontal: -e.currentTarget.clientWidth,
offsetVertical: e.currentTarget.clientHeight + 10
};

popover.open(config);
Expand Down
12 changes: 2 additions & 10 deletions packages/rocketchat-ui-flextab/client/tabs/membersList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals WebRTC popover isRtl */
/* globals WebRTC popover */
import _ from 'underscore';
import {getActions} from './userActions';

Expand Down Expand Up @@ -216,20 +216,12 @@ Template.membersList.events({
e.preventDefault();
const config = {
columns,
mousePosition: () => ({
x: e.currentTarget.getBoundingClientRect().right + 10,
y: e.currentTarget.getBoundingClientRect().bottom + 100
}),
customCSSProperties: () => ({
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`,
left: isRtl() ? `${ e.currentTarget.getBoundingClientRect().left - 10 }px` : undefined
}),
data: {
rid: this._id,
username: instance.data.username,
instance
},
activeElement: e.currentTarget,
currentTarget: e.currentTarget,
onDestroyed:() => {
e.currentTarget.parentElement.classList.remove('active');
}
Expand Down
15 changes: 4 additions & 11 deletions packages/rocketchat-ui-flextab/client/tabs/userInfo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals RoomRoles, UserRoles*/
/* globals RoomRoles UserRoles popover */
import _ from 'underscore';
import s from 'underscore.string';
import moment from 'moment';
Expand Down Expand Up @@ -168,7 +168,7 @@ Template.userInfo.helpers({
return RocketChat.settings.get('Accounts_ManuallyApproveNewUsers') && user.active === false && user.reason;
}
});
/* globals isRtl popover */

Template.userInfo.events({
'click .js-more'(e, instance) {
const actions = more.call(this);
Expand All @@ -193,20 +193,13 @@ Template.userInfo.events({
e.preventDefault();
const config = {
columns,
mousePosition: () => ({
x: e.currentTarget.getBoundingClientRect().right + 10,
y: e.currentTarget.getBoundingClientRect().bottom + 100
}),
customCSSProperties: () => ({
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`,
left: isRtl() ? `${ e.currentTarget.getBoundingClientRect().left - 10 }px` : undefined
}),
data: {
rid: this._id,
username: instance.data.username,
instance
},
activeElement: e.currentTarget
currentTarget: e.currentTarget,
offsetVertical: e.currentTarget.clientHeight + 10
};
popover.open(config);
},
Expand Down
14 changes: 4 additions & 10 deletions packages/rocketchat-ui-message/client/messageBox.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals fileUpload KonchatNotification chatMessages popover isRtl AudioRecorder chatMessages fileUploadHandler*/
/* globals fileUpload KonchatNotification chatMessages popover AudioRecorder chatMessages fileUploadHandler*/
import toastr from 'toastr';
import moment from 'moment';
import _ from 'underscore';
Expand Down Expand Up @@ -449,8 +449,6 @@ Template.messageBox.events({
},
'click .rc-message-box__action-menu'(e) {
const groups = RocketChat.messageBox.actions.get();
const textArea = document.querySelector('.rc-message-box__textarea');

const config = {
popoverClass: 'message-box',
columns: [
Expand All @@ -472,13 +470,9 @@ Template.messageBox.events({
})
}
],
mousePosition: {
x: document.querySelector('.rc-message-box__textarea').getBoundingClientRect().right + 40,
y: document.querySelector('.rc-message-box__textarea').getBoundingClientRect().top
},
customCSSProperties: {
left: isRtl() ? `${ textArea.getBoundingClientRect().left - 10 }px` : undefined
},
offsetVertical: 10,
direction: 'top-inverted',
currentTarget: e.currentTarget.firstElementChild.firstElementChild,
data: {
rid: this._id
},
Expand Down
43 changes: 9 additions & 34 deletions packages/rocketchat-ui-sidenav/client/sidebarHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,8 @@ const toolbarButtons = (user) => {
]
}
],
mousePosition: () => ({
x: e.currentTarget.getBoundingClientRect().left,
y: e.currentTarget.getBoundingClientRect().bottom + 50
}),
customCSSProperties: () => ({
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`,
left: `${ e.currentTarget.getBoundingClientRect().left - 10 }px`
})
currentTarget: e.currentTarget,
offsetVertical: e.currentTarget.clientHeight + 10
};

popover.open(config);
Expand All @@ -125,18 +119,11 @@ const toolbarButtons = (user) => {
const options = [];
const config = {
template: 'sortlist',
mousePosition: () => ({
x: e.currentTarget.getBoundingClientRect().left,
y: e.currentTarget.getBoundingClientRect().bottom + 50
}),
customCSSProperties: () => ({
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`,
left: `${ e.currentTarget.getBoundingClientRect().left - 10 }px`
}),
currentTarget: e.currentTarget,
data: {
// value: instance.form[key].get(),
options
}
},
offsetVertical: e.currentTarget.clientHeight + 10
};
popover.open(config);
}
Expand Down Expand Up @@ -209,14 +196,8 @@ const toolbarButtons = (user) => {
]
}
],
mousePosition: () => ({
x: e.currentTarget.getBoundingClientRect().left,
y: e.currentTarget.getBoundingClientRect().bottom + 50
}),
customCSSProperties: () => ({
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`,
left: `${ e.currentTarget.getBoundingClientRect().left - 10 }px`
})
currentTarget: e.currentTarget,
offsetVertical: e.currentTarget.clientHeight + 10
};

popover.open(config);
Expand Down Expand Up @@ -323,14 +304,8 @@ Template.sidebarHeader.events({
]
}
],
mousePosition: () => ({
x: e.currentTarget.getBoundingClientRect().left,
y: e.currentTarget.getBoundingClientRect().bottom + 50
}),
customCSSProperties: () => ({
top: `${ e.currentTarget.getBoundingClientRect().bottom + 10 }px`,
left: `${ e.currentTarget.getBoundingClientRect().left - 10 }px`
})
currentTarget: e.currentTarget,
offsetVertical: e.currentTarget.clientHeight + 10
};

popover.open(config);
Expand Down
8 changes: 3 additions & 5 deletions packages/rocketchat-ui-sidenav/client/sidebarItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,13 @@ Template.sidebarItem.events({
]
}
],
mousePosition: {
x: e.clientX,
y: e.clientY
},
data: {
template: this.t,
rid: this.rid,
name: this.name
}
},
currentTarget: e.currentTarget,
offsetHorizontal: -e.currentTarget.clientWidth
};

popover.open(config);
Expand Down
Loading