Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: scroll to top when switching dashboard #1040

Merged
merged 4 commits into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/components/Dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ export class Dashboard extends Component {
this.props.selectDashboard(id)

this.setHeaderbarVisibility()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do? Shouldn't need to do anything with the headerbar in app platform...

Copy link
Collaborator Author

@jenniferarnesen jenniferarnesen Sep 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The print view doesn't show the headerbar:

image

From Joe's sketch:

https://www.sketch.com/s/d4547123-e947-4484-89d7-bfc88e2f002f/a/dJZwDb/play


this.scrollToTop()
}
}

Expand All @@ -62,10 +60,6 @@ export class Dashboard extends Component {
}
}

scrollToTop = () => {
window.scrollTo(0, 0)
}

componentDidMount() {
this.setDashboard()
}
Expand Down
7 changes: 7 additions & 0 deletions src/components/Dashboard/ViewDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 -
Expand All @@ -50,13 +55,15 @@ ViewDashboard.propTypes = {
controlBarRows: PropTypes.number,
dashboardIsEditing: PropTypes.bool,
dashboardIsPrinting: PropTypes.bool,
selectedId: PropTypes.string,
}

const mapStateToProps = state => {
return {
dashboardIsEditing: sGetIsEditing(state),
dashboardIsPrinting: sGetIsPrinting(state),
controlBarRows: sGetControlBarUserRows(state),
selectedId: sGetSelectedId(state),
}
}

Expand Down