From d87b34cd0ae5efc3023be921f2e4963c9fabf025 Mon Sep 17 00:00:00 2001 From: DD <liudi08@gmail.com> Date: Fri, 2 Mar 2018 13:50:36 -0500 Subject: [PATCH] Switch to the correct costume number when switching sprites --- src/containers/costume-tab.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/containers/costume-tab.jsx b/src/containers/costume-tab.jsx index 2e897c451..30d138406 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}); } } -- GitLab