Skip to content
Snippets Groups Projects
Commit 4da72835 authored by DD's avatar DD
Browse files

Set index for sounds too. Reseting to sound 0 matches scratch 2 behavior

parent d87b34cd
No related branches found
No related tags found
No related merge requests found
......@@ -46,8 +46,14 @@ class SoundTab extends React.Component {
} = nextProps;
const target = editingTarget && sprites[editingTarget] ? sprites[editingTarget] : stage;
if (!target || !target.sounds) {
return;
}
if (target && target.sounds && this.state.selectedSoundIndex > target.sounds.length - 1) {
// If switching editing targets, reset the sound index
if (this.props.editingTarget !== editingTarget) {
this.setState({selectedSoundIndex: 0});
} else if (this.state.selectedSoundIndex > target.sounds.length - 1) {
this.setState({selectedSoundIndex: Math.max(target.sounds.length - 1, 0)});
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment