Skip to content

Commit

Permalink
fix: fix component initial value
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj committed Jun 15, 2023
1 parent f9e4be4 commit d012ea9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const error = ref<string | undefined>("");
watch(error, () => emit("error", error.value));
//We set the value prop as a reference for update reason
const selectedValue = ref("");
const selectedValue = ref(props.modelValue);
//This function emits the events on update
const emitValueChange = (newValue: string): void => {
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/components/forms/RadioInputComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
orientation="vertical"
:name="id + 'rb'"
v-model="selectedValue"
@bx-radio-button-group-changed="
(event:any) => (selectedValue = event.detail.value)
"
@bx-radio-button-group-changed="updateSelectedValue"
>
<bx-radio-button
v-for="option in modelValue"
Expand All @@ -18,7 +16,7 @@
</template>

<script setup lang="ts">
import { ref, watch } from "vue";
import { ref, watch } from "vue";
import { type CodeDescrType, isEmpty } from "@/core/CommonTypes";
const props = defineProps<{
Expand Down Expand Up @@ -69,4 +67,7 @@ watch(selectedValue, () => {
//We watch for error changes to emit events
watch(error, () => emit("error", error.value));
const updateSelectedValue = (event: any) =>(selectedValue.value = event.detail.value);
</script>

0 comments on commit d012ea9

Please sign in to comment.