diff --git a/scm-ui/ui-components/src/repos/DiffFile.tsx b/scm-ui/ui-components/src/repos/DiffFile.tsx index c8152249b0..edf1d8c79a 100644 --- a/scm-ui/ui-components/src/repos/DiffFile.tsx +++ b/scm-ui/ui-components/src/repos/DiffFile.tsx @@ -4,7 +4,7 @@ import classNames from "classnames"; import styled from "styled-components"; // @ts-ignore import { Decoration, getChangeKey, Hunk } from "react-diff-view"; -import { Button, ButtonGroup } from "../buttons"; +import { ButtonGroup } from "../buttons"; import Tag from "../Tag"; import Icon from "../Icon"; import { Change, ChangeEvent, DiffObjectProps, File, Hunk as HunkType } from "./DiffTypes"; @@ -72,6 +72,14 @@ class DiffFile extends React.Component { }; } + componentDidUpdate(prevProps: Readonly, prevState: Readonly, snapshot?: any): void { + if (this.props.defaultCollapse !== prevProps.defaultCollapse) { + this.setState({ + collapsed: this.defaultCollapse() + }); + } + } + defaultCollapse: () => boolean = () => { const { defaultCollapse, file } = this.props; if (typeof defaultCollapse === "boolean") {