Commit 548708a8 by Torkel Ödegaard

Scroll to top when visualization picker is opened

parent 9cb49d14
...@@ -26,6 +26,7 @@ interface Props { ...@@ -26,6 +26,7 @@ interface Props {
interface State { interface State {
isVizPickerOpen: boolean; isVizPickerOpen: boolean;
searchQuery: string; searchQuery: string;
scrollTop: number;
} }
export class VisualizationTab extends PureComponent<Props, State> { export class VisualizationTab extends PureComponent<Props, State> {
...@@ -39,6 +40,7 @@ export class VisualizationTab extends PureComponent<Props, State> { ...@@ -39,6 +40,7 @@ export class VisualizationTab extends PureComponent<Props, State> {
this.state = { this.state = {
isVizPickerOpen: false, isVizPickerOpen: false,
searchQuery: '', searchQuery: '',
scrollTop: 0,
}; };
} }
...@@ -143,7 +145,7 @@ export class VisualizationTab extends PureComponent<Props, State> { ...@@ -143,7 +145,7 @@ export class VisualizationTab extends PureComponent<Props, State> {
}; };
onOpenVizPicker = () => { onOpenVizPicker = () => {
this.setState({ isVizPickerOpen: true }); this.setState({ isVizPickerOpen: true, scrollTop: 0 });
}; };
onCloseVizPicker = () => { onCloseVizPicker = () => {
...@@ -201,9 +203,14 @@ export class VisualizationTab extends PureComponent<Props, State> { ...@@ -201,9 +203,14 @@ export class VisualizationTab extends PureComponent<Props, State> {
renderHelp = () => <PluginHelp plugin={this.props.plugin} type="help" />; renderHelp = () => <PluginHelp plugin={this.props.plugin} type="help" />;
setScrollTop = (event: React.MouseEvent<HTMLElement>) => {
const target = event.target as HTMLElement;
this.setState({ scrollTop: target.scrollTop });
};
render() { render() {
const { plugin } = this.props; const { plugin } = this.props;
const { isVizPickerOpen, searchQuery } = this.state; const { isVizPickerOpen, searchQuery, scrollTop } = this.state;
const pluginHelp: EditorToolbarView = { const pluginHelp: EditorToolbarView = {
heading: 'Help', heading: 'Help',
...@@ -212,7 +219,8 @@ export class VisualizationTab extends PureComponent<Props, State> { ...@@ -212,7 +219,8 @@ export class VisualizationTab extends PureComponent<Props, State> {
}; };
return ( return (
<EditorTabBody heading="Visualization" renderToolbar={this.renderToolbar} toolbarItems={[pluginHelp]}> <EditorTabBody heading="Visualization" renderToolbar={this.renderToolbar} toolbarItems={[pluginHelp]}
scrollTop={scrollTop} setScrollTop={this.setScrollTop}>
<> <>
<FadeIn in={isVizPickerOpen} duration={200} unmountOnExit={true}> <FadeIn in={isVizPickerOpen} duration={200} unmountOnExit={true}>
<VizTypePicker <VizTypePicker
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment