diff --git a/src/core/components/model-example.jsx b/src/core/components/model-example.jsx index e7d13ada..499da2de 100644 --- a/src/core/components/model-example.jsx +++ b/src/core/components/model-example.jsx @@ -15,13 +15,13 @@ export default class ModelExample extends React.Component { constructor(props, context) { super(props, context) - let { getConfigs } = this.props + let { getConfigs, isExecute } = this.props let { defaultModelRendering } = getConfigs() if (defaultModelRendering !== "example" && defaultModelRendering !== "model") { defaultModelRendering = "example" } this.state = { - activeTab: defaultModelRendering + activeTab: isExecute ? "example" : defaultModelRendering } } @@ -33,6 +33,12 @@ export default class ModelExample extends React.Component { }) } + componentWillReceiveProps(props) { + if (props.isExecute && props.isExecute !== this.props.isExecute) { + this.setState({ activeTab: "example" }) + } + } + render() { let { getComponent, specSelectors, schema, example, isExecute, getConfigs, specPath } = this.props let { defaultModelExpandDepth } = getConfigs() @@ -40,19 +46,19 @@ export default class ModelExample extends React.Component { return
{ - (isExecute || this.state.activeTab === "example") && example + this.state.activeTab === "example" && example } { - !isExecute && this.state.activeTab === "model" &&