Merge pull request #14140 from desktop/fix-markdown-height

Fix height issues with Markdown component
This commit is contained in:
Sergio Padrino 2022-03-14 10:33:49 +01:00 committed by GitHub
commit 76f19eb706
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 5 deletions

View file

@ -147,15 +147,17 @@ export class SandboxedMarkdown extends React.PureComponent<
*/
const docEl = frameRef.contentDocument.documentElement.querySelector(
'#content'
)
) as HTMLDivElement
if (docEl === null) {
return
}
// Not sure why the content height != body height exactly. But, 50px seems
// to prevent scrollbar/content cut off.
const divHeight = docEl.clientHeight + 50
// Not sure why the content height != body height exactly. But we need to
// set the height explicitly to prevent scrollbar/content cut off.
const divHeight = docEl.clientHeight
this.frameContainingDivRef.style.height = `${divHeight}px`
docEl.style.height = `${divHeight}px`
this.props.onMarkdownParsed?.()
}

View file

@ -9,6 +9,14 @@ desktop font-size variables. (This is not meant to be an exhaustive list of
changes from the original, just a note that this will not match 1-1)
*/
#content {
/*
We need to set overflow-y to hidden to make sure this element calculates the
right height to fit its content.
*/
overflow-y: hidden;
}
.markdown-body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
font-size: var(--font-size);

View file

@ -1,6 +1,5 @@
.sandboxed-markdown-iframe-container {
position: relative;
min-height: 50px;
.sandboxed-markdown-component {
// With combination of setting height of containing div.