From dd8f7aa7a9c7f7240b92c347006ff8df7e91bdd5 Mon Sep 17 00:00:00 2001 From: Dominik Prokop Date: Tue, 22 Jan 2019 10:58:31 +0100 Subject: [PATCH] CustomScrollbar - expose underlying's react-custom-scrollbars API to allow scroll tracks config. Updated config for Graph legend not to display horizontal scroll track which caused legend being not accessible in ceertain situations (e.g. when native OS scroll overlay disabled) --- .../components/CustomScrollbar/CustomScrollbar.tsx | 12 +++++++----- public/app/plugins/panel/graph/Legend/Legend.tsx | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/grafana-ui/src/components/CustomScrollbar/CustomScrollbar.tsx b/packages/grafana-ui/src/components/CustomScrollbar/CustomScrollbar.tsx index eb50944ad35..434ee03c7a1 100644 --- a/packages/grafana-ui/src/components/CustomScrollbar/CustomScrollbar.tsx +++ b/packages/grafana-ui/src/components/CustomScrollbar/CustomScrollbar.tsx @@ -9,6 +9,8 @@ interface Props { autoHideDuration?: number; autoMaxHeight?: string; hideTracksWhenNotNeeded?: boolean; + renderTrackHorizontal?: React.FunctionComponent; + renderTrackVertical?: React.FunctionComponent; scrollTop?: number; setScrollTop: (value: React.MouseEvent) => void; autoHeightMin?: number | string; @@ -26,7 +28,7 @@ export class CustomScrollbar extends PureComponent { autoMaxHeight: '100%', hideTracksWhenNotNeeded: false, setScrollTop: () => {}, - autoHeightMin: '0' + autoHeightMin: '0', }; private ref: React.RefObject; @@ -45,7 +47,7 @@ export class CustomScrollbar extends PureComponent { } else { ref.scrollTop(this.props.scrollTop); } - } + } } componentDidMount() { @@ -57,7 +59,7 @@ export class CustomScrollbar extends PureComponent { } render() { - const { customClassName, children, autoMaxHeight } = this.props; + const { customClassName, children, autoMaxHeight, renderTrackHorizontal, renderTrackVertical } = this.props; return ( { // These autoHeightMin & autoHeightMax options affect firefox and chrome differently. // Before these where set to inhert but that caused problems with cut of legends in firefox autoHeightMax={autoMaxHeight} - renderTrackHorizontal={props =>
} - renderTrackVertical={props =>
} + renderTrackHorizontal={renderTrackHorizontal || (props =>
)} + renderTrackVertical={renderTrackVertical || (props =>
)} renderThumbHorizontal={props =>
} renderThumbVertical={props =>
} renderView={props =>
} diff --git a/public/app/plugins/panel/graph/Legend/Legend.tsx b/public/app/plugins/panel/graph/Legend/Legend.tsx index b83cd7bd88c..47a84622947 100644 --- a/public/app/plugins/panel/graph/Legend/Legend.tsx +++ b/public/app/plugins/panel/graph/Legend/Legend.tsx @@ -311,7 +311,7 @@ class LegendTableHeaderItem extends PureComponent { render() { return ( - +
}> );