fix(frontend): revert tab to valid values if navigating to an invalid one

This commit is contained in:
MiniDigger | Martin 2022-11-26 10:35:32 +01:00
parent 9b496538ed
commit 8c6d1d3b04

View File

@ -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;