Added onLoad()s and tweaker onToggle() to support ScrollTo functionality for Models (#5237)

This commit is contained in:
geraldglynn
2020-06-15 21:04:14 +01:00
committed by GitHub
parent b3fc05b3fe
commit 59bbe4ff2f
3 changed files with 28 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import React, { Component } from "react"
import PropTypes from "prop-types"
import Im from "immutable"
export default class ModelCollapse extends Component {
static propTypes = {
@@ -11,6 +12,8 @@ export default class ModelCollapse extends Component {
classes: PropTypes.string,
onToggle: PropTypes.func,
hideSelfOnExpand: PropTypes.bool,
layoutActions: PropTypes.object,
layoutSelectors: PropTypes.object.isRequired
}
static defaultProps = {
@@ -58,6 +61,16 @@ export default class ModelCollapse extends Component {
})
}
onLoad = (ref) => {
if(ref) {
const name = this.props.modelName
const scrollToKey = this.props.layoutSelectors.getScrollToKey()
if( Im.is(scrollToKey, Im.fromJS(["models", name])) ) this.toggleCollapsed()
this.props.layoutActions.readyToScroll(["models", name], ref.parentElement)
}
}
render () {
const { title, classes } = this.props