Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 66c7a13

Browse files
authored
Fixes #572 - Body styles getting overridden (#660)
* Fixes #572 - Body styles getting overriden * Fix build
1 parent b65502e commit 66c7a13

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/styles/index.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,10 @@ body {
4242

4343
height: 100%;
4444
}
45+
46+
.rc-livechat-mobile-full-screen {
47+
overflow: hidden;
48+
49+
width: 100%;
50+
height: 100%;
51+
}

src/widget.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const WIDGET_OPEN_HEIGHT = 525;
1111
const WIDGET_MINIMIZED_WIDTH = 54;
1212
const WIDGET_MINIMIZED_HEIGHT = 54;
1313
const WIDGET_MARGIN = 16;
14-
const FULLSCREEN_DOCUMENT_CONFIG = 'overflow: hidden; height: 100%; width: 100%;';
1514

1615

1716
window.RocketChat = window.RocketChat || { _: [] };
@@ -21,7 +20,6 @@ let iframe;
2120
let hookQueue = [];
2221
let ready = false;
2322
let smallScreen = false;
24-
let bodyStyle;
2523
let scrollPosition;
2624
let widget_height;
2725

@@ -74,10 +72,9 @@ function callHook(action, params) {
7472
const updateWidgetStyle = (isOpened) => {
7573
if (smallScreen && isOpened) {
7674
scrollPosition = document.documentElement.scrollTop;
77-
bodyStyle = document.body.style.cssText;
78-
document.body.style.cssText += FULLSCREEN_DOCUMENT_CONFIG;
75+
document.body.classList.add('rc-livechat-mobile-full-screen');
7976
} else {
80-
document.body.style.cssText = bodyStyle;
77+
document.body.classList.remove('rc-livechat-mobile-full-screen');
8178
if (smallScreen) {
8279
document.documentElement.scrollTop = scrollPosition;
8380
}
@@ -235,11 +232,11 @@ const api = {
235232
},
236233

237234
resetDocumentStyle() {
238-
document.body.style.cssText = bodyStyle;
235+
document.body.classList.remove('rc-livechat-mobile-full-screen');
239236
},
240237

241238
setFullScreenDocumentMobile() {
242-
document.body.style.cssText += smallScreen && FULLSCREEN_DOCUMENT_CONFIG;
239+
smallScreen && document.body.classList.add('rc-livechat-mobile-full-screen');
243240
},
244241
};
245242

0 commit comments

Comments
 (0)