Skip to content
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
21 changes: 12 additions & 9 deletions src/core/components/content-type.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { fromJS } from "immutable"
const noop = ()=>{}

export default class ContentType extends React.Component {

static propTypes = {
ariaControls: PropTypes.string,
contentTypes: PropTypes.oneOfType([ImPropTypes.list, ImPropTypes.set, ImPropTypes.seq]),
Expand All @@ -24,19 +23,22 @@ export default class ContentType extends React.Component {
}

componentDidMount() {
// Needed to populate the form, initially
if(this.props.contentTypes) {
this.props.onChange(this.props.contentTypes.first())
// Populate the form initially
const { contentTypes, onChange } = this.props
if (contentTypes && contentTypes.size) {
onChange(contentTypes.first())
}
}

UNSAFE_componentWillReceiveProps(nextProps) {
if(!nextProps.contentTypes || !nextProps.contentTypes.size) {
componentDidUpdate() {
const { contentTypes, value, onChange } = this.props

if (!contentTypes || !contentTypes.size) {
return
}

if(!nextProps.contentTypes.includes(nextProps.value)) {
nextProps.onChange(nextProps.contentTypes.first())
if (!contentTypes.includes(value)) {
onChange(contentTypes.first())
}
}

Expand All @@ -58,4 +60,5 @@ export default class ContentType extends React.Component {
</div>
)
}
}

}
12 changes: 6 additions & 6 deletions src/core/containers/OperationContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ export default class OperationContainer extends PureComponent {
}
}

UNSAFE_componentWillReceiveProps(nextProps) {
const { response, isShown } = nextProps
componentDidUpdate(prevProps) {
const { response, isShown } = this.props
const resolvedSubtree = this.getResolvedSubtree()

if(response !== this.props.response) {
if (response !== prevProps.response) {
this.setState({ executeInProgress: false })
}

if(isShown && resolvedSubtree === undefined) {
if (isShown && resolvedSubtree === undefined && !prevProps.isShown) {
this.requestResolvedSubtree()
}
}
Expand Down