Fixed scrollbar not visible due to content being added a bit after mount, fixes #15711

This commit is contained in:
Torkel Ödegaard
2019-03-05 14:32:33 +01:00
parent 12b6ab2ddd
commit cd78f0bef2
4 changed files with 19 additions and 1 deletions
@@ -15,6 +15,7 @@ interface Props {
scrollTop?: number;
setScrollTop: (event: any) => void;
autoHeightMin?: number | string;
updateAfterMountMs?: number;
}
/**
@@ -48,6 +49,20 @@ export class CustomScrollbar extends Component<Props> {
componentDidMount() {
this.updateScroll();
// this logic is to make scrollbar visible when content is added body after mount
if (this.props.updateAfterMountMs) {
setTimeout(() => this.updateAfterMount(), this.props.updateAfterMountMs);
}
}
updateAfterMount() {
if (this.ref && this.ref.current) {
const scrollbar = this.ref.current as any;
if (scrollbar.update) {
scrollbar.update();
}
}
}
componentDidUpdate() {