diff --git a/src/containers/costume-tab.jsx b/src/containers/costume-tab.jsx index 2e897c451031eae029dad95609c484f2ef645d72..30d1384067a0428fa46ba55b6f80105677ca3d92 100644 --- a/src/containers/costume-tab.jsx +++ b/src/containers/costume-tab.jsx @@ -90,7 +90,14 @@ class CostumeTab extends React.Component { } = nextProps; const target = editingTarget && sprites[editingTarget] ? sprites[editingTarget] : stage; - if (target && target.costumes && this.state.selectedCostumeIndex > target.costumes.length - 1) { + if (!target || !target.costumes) { + return; + } + + // If switching editing targets, update the costume index + if (this.props.editingTarget !== editingTarget) { + this.setState({selectedCostumeIndex: target.currentCostume}); + } else if (this.state.selectedCostumeIndex > target.costumes.length - 1) { this.setState({selectedCostumeIndex: target.costumes.length - 1}); } }