When messages must scroll horizontally, add 20px to the computed height for scrollbar #1762

This commit is contained in:
Ben Gotow 2020-04-16 22:30:38 -05:00
parent 4133537ddc
commit 86ed6db088

View file

@ -153,16 +153,25 @@ export default class EmailFrame extends React.Component<EmailFrameProps> {
// If documentElement has a scroll height, prioritize that as height
// If not, fall back to body scroll height by setting it to auto
let height = 0;
let width = 0;
if (doc && doc.documentElement && doc.documentElement.scrollHeight > 0) {
width = doc.documentElement.scrollWidth;
height = doc.documentElement.scrollHeight;
} else if (doc && doc.body) {
const style = window.getComputedStyle(doc.body);
if (style.height === '0px') {
doc.body.style.height = 'auto';
}
width = doc.body.scrollWidth;
height = doc.body.scrollHeight;
}
if (width > iframeEl.clientWidth) {
// the message will scroll horizontally, and we need to add 20px to the height of
// the iframe to allow for it's scrollbar. Otherwise it covers the last line of text.
height += 20;
}
this._iframeComponent.setHeightQuietly(height);
this._iframeWrapperEl.style.height = `${height}px`;
};