Fix empty content in modal view of collapsed panel

This commit is contained in:
Florian Scholdei
2020-10-21 10:50:14 +02:00
parent 36133e639c
commit 6a93d861fa

View File

@@ -415,30 +415,31 @@ class DiffFile extends React.Component<Props, State> {
const { file, collapsed, sideBySide, diffExpander, expansionError } = this.state; const { file, collapsed, sideBySide, diffExpander, expansionError } = this.state;
const viewType = sideBySide ? "split" : "unified"; const viewType = sideBySide ? "split" : "unified";
let body = null; const fileAnnotations = fileAnnotationFactory ? fileAnnotationFactory(file) : null;
const innerContent = (
<div className="panel-block is-paddingless">
{fileAnnotations}
<TokenizedDiffView className={viewType} viewType={viewType} file={file}>
{(hunks: HunkType[]) =>
hunks?.map((hunk, n) => {
return this.renderHunk(file, diffExpander.getHunk(n), n);
})
}
</TokenizedDiffView>
</div>
);
let icon = "angle-right"; let icon = "angle-right";
let body = null;
if (!collapsed) { if (!collapsed) {
const fileAnnotations = fileAnnotationFactory ? fileAnnotationFactory(file) : null;
icon = "angle-down"; icon = "angle-down";
body = ( body = innerContent;
<div className="panel-block is-paddingless">
{fileAnnotations}
<TokenizedDiffView className={viewType} viewType={viewType} file={file}>
{(hunks: HunkType[]) =>
hunks?.map((hunk, n) => {
return this.renderHunk(file, diffExpander.getHunk(n), n);
})
}
</TokenizedDiffView>
</div>
);
} }
const collapseIcon = this.hasContent(file) ? <Icon name={icon} color="inherit" /> : null; const collapseIcon = this.hasContent(file) ? <Icon name={icon} color="inherit" /> : null;
const fileControls = fileControlFactory ? fileControlFactory(file, this.setCollapse) : null; const fileControls = fileControlFactory ? fileControlFactory(file, this.setCollapse) : null;
const openInFullscreen = file?.hunks?.length ? ( const openInFullscreen = file?.hunks?.length ? (
<OpenInFullscreenButton <OpenInFullscreenButton
modalTitle={file.type === "delete" ? file.oldPath : file.newPath} modalTitle={file.type === "delete" ? file.oldPath : file.newPath}
modalBody={<MarginlessModalContent>{body}</MarginlessModalContent>} modalBody={<MarginlessModalContent>{innerContent}</MarginlessModalContent>}
/> />
) : null; ) : null;
const sideBySideToggle = file?.hunks?.length && ( const sideBySideToggle = file?.hunks?.length && (