Skip to content

Commit

Permalink
fix(DamageCalculatorPage): fix tabs changing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rudnovd committed Apr 13, 2022
1 parent 6f85955 commit 462c814
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/views/DamageCalculatorPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<DamageCalculator
v-for="(calculator, index) in calculators"
v-show="activeIndex === index"
:key="`damage-calculator-tab-${index}`"
:key="`damage-calculator-tab-${index}-${Math.random()}`"
:battle-value="calculator"
/>
</TransitionGroup>
Expand Down Expand Up @@ -236,9 +236,14 @@ export default defineComponent({
// If current calculator selected for delete
if (activeIndex.value === index) {
// Switch to previous or first tab
activeIndex.value = calculators.value.length > 1 ? index - 1 : 0
} else {
if (index > 0 && index < calculators.value.length - 1) {
activeIndex.value = index + 1
} else if (index > 0 && index !== calculators.value.length - 1) {
activeIndex.value = index - 1
} else if (index < calculators.value.length - 1) {
activeIndex.value = 0
}
} else if (index < activeIndex.value) {
activeIndex.value = calculators.value.length - 1
}
}
Expand Down

0 comments on commit 462c814

Please sign in to comment.