fix(Models): use specPath for isShownKey to toggle models (#6200)
Co-authored-by: Tim Lai <timothy.lai@gmail.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import React, { Component } from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import ImPropTypes from "react-immutable-proptypes"
|
||||
import Im from "immutable"
|
||||
|
||||
export default class ModelCollapse extends Component {
|
||||
@@ -13,7 +14,8 @@ export default class ModelCollapse extends Component {
|
||||
onToggle: PropTypes.func,
|
||||
hideSelfOnExpand: PropTypes.bool,
|
||||
layoutActions: PropTypes.object,
|
||||
layoutSelectors: PropTypes.object.isRequired
|
||||
layoutSelectors: PropTypes.object.isRequired,
|
||||
specPath: ImPropTypes.list.isRequired,
|
||||
}
|
||||
|
||||
static defaultProps = {
|
||||
@@ -21,7 +23,8 @@ export default class ModelCollapse extends Component {
|
||||
expanded: false,
|
||||
title: null,
|
||||
onToggle: () => {},
|
||||
hideSelfOnExpand: false
|
||||
hideSelfOnExpand: false,
|
||||
specPath: Im.List([]),
|
||||
}
|
||||
|
||||
constructor(props, context) {
|
||||
@@ -63,11 +66,10 @@ 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)
|
||||
if( Im.is(scrollToKey, this.props.specPath) ) this.toggleCollapsed()
|
||||
this.props.layoutActions.readyToScroll(this.props.specPath, ref.parentElement)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +85,7 @@ export default class ModelCollapse extends Component {
|
||||
}
|
||||
|
||||
return (
|
||||
<span className={classes || ""}>
|
||||
<span className={classes || ""} ref={this.onLoad}>
|
||||
{ title && <span onClick={this.toggleCollapsed} className="pointer">{title}</span> }
|
||||
<span onClick={ this.toggleCollapsed } className="pointer">
|
||||
<span className={ "model-toggle" + ( this.state.expanded ? "" : " collapsed" ) }></span>
|
||||
|
||||
Reference in New Issue
Block a user