diff --git a/packages/grafana-ui/src/components/CustomScrollbar/CustomScrollbar.tsx b/packages/grafana-ui/src/components/CustomScrollbar/CustomScrollbar.tsx
index f2f6b236e14..3546148f57c 100644
--- a/packages/grafana-ui/src/components/CustomScrollbar/CustomScrollbar.tsx
+++ b/packages/grafana-ui/src/components/CustomScrollbar/CustomScrollbar.tsx
@@ -42,9 +42,10 @@ export class CustomScrollbar extends Component {
updateScroll() {
const ref = this.ref.current;
+ const { scrollTop } = this.props;
- if (ref && !isNil(this.props.scrollTop)) {
- ref.scrollTop(this.props.scrollTop);
+ if (ref && !isNil(scrollTop)) {
+ ref.scrollTop(scrollTop);
}
}
@@ -70,6 +71,44 @@ export class CustomScrollbar extends Component {
this.updateScroll();
}
+ renderTrack = (track: 'track-vertical' | 'track-horizontal', hideTrack: boolean | undefined, passedProps: any) => {
+ return (
+
+ );
+ };
+
+ renderThumb = (thumb: 'thumb-horizontal' | 'thumb-vertical', passedProps: any) => {
+ return ;
+ };
+
+ renderTrackHorizontal = (passedProps: any) => {
+ return this.renderTrack('track-horizontal', this.props.hideHorizontalTrack, passedProps);
+ };
+
+ renderTrackVertical = (passedProps: any) => {
+ return this.renderTrack('track-vertical', this.props.hideVerticalTrack, passedProps);
+ };
+
+ renderThumbHorizontal = (passedProps: any) => {
+ return this.renderThumb('thumb-horizontal', passedProps);
+ };
+
+ renderThumbVertical = (passedProps: any) => {
+ return this.renderThumb('thumb-vertical', passedProps);
+ };
+
+ renderView = (passedProps: any) => {
+ return ;
+ };
+
render() {
const {
className,
@@ -80,8 +119,6 @@ export class CustomScrollbar extends Component {
autoHide,
autoHideTimeout,
hideTracksWhenNotNeeded,
- hideHorizontalTrack,
- hideVerticalTrack,
} = this.props;
return (
@@ -97,31 +134,11 @@ export class CustomScrollbar extends Component {
// Before these where set to inhert but that caused problems with cut of legends in firefox
autoHeightMax={autoHeightMax}
autoHeightMin={autoHeightMin}
- renderTrackHorizontal={props => (
-
- )}
- renderTrackVertical={props => (
-
- )}
- renderThumbHorizontal={props => }
- renderThumbVertical={props => }
- renderView={props => }
+ renderTrackHorizontal={this.renderTrackHorizontal}
+ renderTrackVertical={this.renderTrackVertical}
+ renderThumbHorizontal={this.renderThumbHorizontal}
+ renderThumbVertical={this.renderThumbVertical}
+ renderView={this.renderView}
>
{children}
diff --git a/packages/grafana-ui/src/components/CustomScrollbar/__snapshots__/CustomScrollbar.test.tsx.snap b/packages/grafana-ui/src/components/CustomScrollbar/__snapshots__/CustomScrollbar.test.tsx.snap
index b348f7dd8bd..2d941bb1767 100644
--- a/packages/grafana-ui/src/components/CustomScrollbar/__snapshots__/CustomScrollbar.test.tsx.snap
+++ b/packages/grafana-ui/src/components/CustomScrollbar/__snapshots__/CustomScrollbar.test.tsx.snap
@@ -37,7 +37,7 @@ exports[`CustomScrollbar renders correctly 1`] = `
{
showLoadingState: false,
fullscreenPanel: null,
scrollTop: 0,
+ updateScrollTop: null,
rememberScrollTop: 0,
};
@@ -168,7 +170,7 @@ export class DashboardPage extends PureComponent
{
isEditing: false,
isFullscreen: false,
fullscreenPanel: null,
- scrollTop: this.state.rememberScrollTop,
+ updateScrollTop: this.state.rememberScrollTop,
},
this.triggerPanelsRendering.bind(this)
);
@@ -204,7 +206,7 @@ export class DashboardPage extends PureComponent {
setScrollTop = (e: MouseEvent): void => {
const target = e.target as HTMLElement;
- this.setState({ scrollTop: target.scrollTop });
+ this.setState({ scrollTop: target.scrollTop, updateScrollTop: null });
};
onAddPanel = () => {
@@ -251,7 +253,7 @@ export class DashboardPage extends PureComponent {
render() {
const { dashboard, editview, $injector, isInitSlow, initError } = this.props;
- const { isSettingsOpening, isEditing, isFullscreen, scrollTop } = this.state;
+ const { isSettingsOpening, isEditing, isFullscreen, scrollTop, updateScrollTop } = this.state;
if (!dashboard) {
if (isInitSlow) {
@@ -285,9 +287,9 @@ export class DashboardPage extends PureComponent {
/>
diff --git a/public/app/features/dashboard/containers/__snapshots__/DashboardPage.test.tsx.snap b/public/app/features/dashboard/containers/__snapshots__/DashboardPage.test.tsx.snap
index 20fc00cafc0..d6be7658841 100644
--- a/public/app/features/dashboard/containers/__snapshots__/DashboardPage.test.tsx.snap
+++ b/public/app/features/dashboard/containers/__snapshots__/DashboardPage.test.tsx.snap
@@ -111,7 +111,7 @@ exports[`DashboardPage Dashboard init completed Should render dashboard grid 1`
autoHideTimeout={200}
className="custom-scrollbar--page"
hideTracksWhenNotNeeded={false}
- scrollTop={0}
+ scrollTop={null}
setScrollTop={[Function]}
updateAfterMountMs={500}
>
@@ -349,7 +349,7 @@ exports[`DashboardPage When dashboard has editview url state should render setti
autoHideTimeout={200}
className="custom-scrollbar--page"
hideTracksWhenNotNeeded={false}
- scrollTop={0}
+ scrollTop={null}
setScrollTop={[Function]}
updateAfterMountMs={500}
>