mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-03-07 15:31:00 +08:00
fix(frontend): revert tab to valid values if navigating to an invalid one
This commit is contained in:
parent
9b496538ed
commit
8c6d1d3b04
@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed } from "vue";
|
||||
import { computed, watch } from "vue";
|
||||
import Button from "~/lib/components/design/Button.vue";
|
||||
import Link from "~/lib/components/design/Link.vue";
|
||||
|
||||
@ -11,6 +11,12 @@ const internalValue = computed({
|
||||
set: (value) => emit("update:modelValue", value),
|
||||
});
|
||||
|
||||
watch(internalValue, (n) => {
|
||||
if (props.tabs.length > 0 && !props.tabs.some((t) => t.value === n)) {
|
||||
internalValue.value = props.tabs[0].value;
|
||||
}
|
||||
});
|
||||
|
||||
export interface Tab {
|
||||
value: string;
|
||||
header: string;
|
||||
|
Loading…
Reference in New Issue
Block a user