fix: Fixes unread view blocking page scroll (#2727)

* fix: Fixes unread view blocking page scroll

* Update sdk.js

* Fixes the height issue for unread view

* Fix unread message position issue

* Code climate fixes

* Fixes height issue for large messages

* Fixes height issue on unread view

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Nithin David Thomas 2021-08-07 11:56:15 +05:30 committed by GitHub
parent b58ca21f0b
commit 9c257578b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 67 additions and 5 deletions

View file

@ -140,7 +140,10 @@ export const IFrameHelper = {
}
},
onLocationChange: ({ referrerURL, referrerHost }) => {
IFrameHelper.sendMessage('change-url', { referrerURL, referrerHost });
IFrameHelper.sendMessage('change-url', {
referrerURL,
referrerHost,
});
},
setUnreadMode: message => {
@ -175,6 +178,22 @@ export const IFrameHelper = {
const holderEl = document.querySelector('.woot-widget-holder');
removeClass(holderEl, 'has-unread-view');
},
updateIframeHeight: message => {
setTimeout(() => {
const iframe = IFrameHelper.getAppFrame();
const scrollableMessageHeight =
iframe.contentWindow.document.querySelector('.unread-messages')
.scrollHeight + 40;
const updatedIframeHeight = message.isFixedHeight
? `${scrollableMessageHeight}px`
: '100%';
iframe.setAttribute(
'style',
`height: ${updatedIframeHeight} !important`
);
}, 100);
},
},
pushEvent: eventName => {
IFrameHelper.sendMessage('push-event', { eventName });