diff --git a/frontend/src/components/ScheduleCreation.vue b/frontend/src/components/ScheduleCreation.vue index 6543ec959..3663f1a0d 100644 --- a/frontend/src/components/ScheduleCreation.vue +++ b/frontend/src/components/ScheduleCreation.vue @@ -721,7 +721,7 @@ watch( -import { ref, onMounted } from 'vue'; +import { ref, onMounted, watch } from 'vue'; import { useI18n } from 'vue-i18n'; // component constants @@ -16,7 +16,11 @@ interface Props { label?: string; // input label noLegend?: boolean; // hide "on" and "off" labels } -const props = defineProps(); +const props = withDefaults(defineProps(), { + disabled: false, + label: null, + noLegend: true, +}); // current state const state = ref(false); @@ -29,6 +33,15 @@ const toggleState = () => { emit('changed', state.value); } }; + +// Update state if parent changes active prop +// e.g. after initializing async data +watch( + () => props.active, + () => { + state.value = props.active; + } +);