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

View File

@ -15,6 +15,7 @@ interface Props {
scrollTop?: number; scrollTop?: number;
setScrollTop: (event: any) => void; setScrollTop: (event: any) => void;
autoHeightMin?: number | string; autoHeightMin?: number | string;
updateAfterMountMs?: number;
} }
/** /**
@ -48,6 +49,20 @@ export class CustomScrollbar extends Component<Props> {
componentDidMount() { componentDidMount() {
this.updateScroll(); 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() { componentDidUpdate() {

View File

@ -272,6 +272,7 @@ export class DashboardPage extends PureComponent<Props, State> {
autoHeightMin={'100%'} autoHeightMin={'100%'}
setScrollTop={this.setScrollTop} setScrollTop={this.setScrollTop}
scrollTop={scrollTop} scrollTop={scrollTop}
updateAfterMountMs={500}
className="custom-scrollbar--page" className="custom-scrollbar--page"
> >
{editview && <DashboardSettings dashboard={dashboard} />} {editview && <DashboardSettings dashboard={dashboard} />}

View File

@ -113,6 +113,7 @@ exports[`DashboardPage Dashboard init completed Should render dashboard grid 1`
hideTracksWhenNotNeeded={false} hideTracksWhenNotNeeded={false}
scrollTop={0} scrollTop={0}
setScrollTop={[Function]} setScrollTop={[Function]}
updateAfterMountMs={500}
> >
<div <div
className="dashboard-container" className="dashboard-container"
@ -349,6 +350,7 @@ exports[`DashboardPage When dashboard has editview url state should render setti
hideTracksWhenNotNeeded={false} hideTracksWhenNotNeeded={false}
scrollTop={0} scrollTop={0}
setScrollTop={[Function]} setScrollTop={[Function]}
updateAfterMountMs={500}
> >
<DashboardSettings <DashboardSettings
dashboard={ dashboard={

View File

@ -118,7 +118,7 @@ export class EditorTabBody extends PureComponent<Props, State> {
{toolbarItems.map(item => this.renderButton(item))} {toolbarItems.map(item => this.renderButton(item))}
</div> </div>
<div className="panel-editor__scroll"> <div className="panel-editor__scroll">
<CustomScrollbar autoHide={false} scrollTop={scrollTop} setScrollTop={setScrollTop}> <CustomScrollbar autoHide={false} scrollTop={scrollTop} setScrollTop={setScrollTop} updateAfterMountMs={300}>
<div className="panel-editor__content"> <div className="panel-editor__content">
<FadeIn in={isOpen} duration={200} unmountOnExit={true}> <FadeIn in={isOpen} duration={200} unmountOnExit={true}>
{openView && this.renderOpenView(openView)} {openView && this.renderOpenView(openView)}