diff --git a/src/components/Dashboard/Dashboard.js b/src/components/Dashboard/Dashboard.js index fc20fa600..88d155df7 100644 --- a/src/components/Dashboard/Dashboard.js +++ b/src/components/Dashboard/Dashboard.js @@ -48,8 +48,6 @@ export class Dashboard extends Component { this.props.selectDashboard(id) this.setHeaderbarVisibility() - - this.scrollToTop() } } @@ -62,10 +60,6 @@ export class Dashboard extends Component { } } - scrollToTop = () => { - window.scrollTo(0, 0) - } - componentDidMount() { this.setDashboard() } diff --git a/src/components/Dashboard/ViewDashboard.js b/src/components/Dashboard/ViewDashboard.js index fc2e00b00..3b0773f8f 100644 --- a/src/components/Dashboard/ViewDashboard.js +++ b/src/components/Dashboard/ViewDashboard.js @@ -9,6 +9,7 @@ import DashboardsBar from '../ControlBar/DashboardsBar' import DashboardVerticalOffset from './DashboardVerticalOffset' import { sGetIsEditing } from '../../reducers/editDashboard' import { sGetIsPrinting } from '../../reducers/printDashboard' +import { sGetSelectedId } from '../../reducers/selected' import { sGetControlBarUserRows } from '../../reducers/controlBar' import { acClearEditDashboard } from '../../actions/editDashboard' import { acClearPrintDashboard } from '../../actions/printDashboard' @@ -26,6 +27,10 @@ export const ViewDashboard = props => { } }, [props.dashboardIsEditing, props.dashboardIsPrinting]) + useEffect(() => { + document.querySelector('.dashboard-wrapper')?.scroll(0, 0) + }, [props.selectedId]) + const height = window.innerHeight - HEADERBAR_HEIGHT - @@ -50,6 +55,7 @@ ViewDashboard.propTypes = { controlBarRows: PropTypes.number, dashboardIsEditing: PropTypes.bool, dashboardIsPrinting: PropTypes.bool, + selectedId: PropTypes.string, } const mapStateToProps = state => { @@ -57,6 +63,7 @@ const mapStateToProps = state => { dashboardIsEditing: sGetIsEditing(state), dashboardIsPrinting: sGetIsPrinting(state), controlBarRows: sGetControlBarUserRows(state), + selectedId: sGetSelectedId(state), } }