We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 12f1ebf + 0ca74db commit 300b09eCopy full SHA for 300b09e
1 file changed
src/containers/sound-tab.jsx
@@ -73,9 +73,14 @@ class SoundTab extends React.Component {
73
74
// If switching editing targets, reset the sound index
75
if (prevProps.editingTarget !== editingTarget) {
76
- this.setState({selectedSoundIndex: 0});
77
- } else if (this.state.selectedSoundIndex > target.sounds.length - 1) {
78
- this.setState({selectedSoundIndex: Math.max(target.sounds.length - 1, 0)});
+ if (this.state.selectedSoundIndex !== 0) {
+ this.setState({selectedSoundIndex: 0});
+ }
79
+ } else {
80
+ const maxSoundIndex = Math.max(target.sounds.length - 1, 0);
81
+ if (this.state.selectedSoundIndex > maxSoundIndex) {
82
+ this.setState({selectedSoundIndex: maxSoundIndex});
83
84
}
85
86
0 commit comments