mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-27 02:10:40 +01:00
chore: uniformize defineModel placement and emits
This commit is contained in:
@@ -47,6 +47,13 @@ const props = withDefaults(defineProps<RadioGroupProps<T>>(), { orientation: 've
|
||||
const emits = defineEmits<RadioGroupEmits>()
|
||||
defineSlots<RadioGroupSlots<T>>()
|
||||
|
||||
const modelValue = defineModel<T>({
|
||||
set(value) {
|
||||
emits('change', value)
|
||||
return value
|
||||
}
|
||||
})
|
||||
|
||||
const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'defaultValue', 'orientation', 'loop', 'required'), emits)
|
||||
|
||||
const { emitFormChange, color, name, size, inputId: _inputId, disabled } = useFormField<RadioGroupProps<T>>(props)
|
||||
@@ -80,13 +87,6 @@ const normalizedOptions = computed(() => {
|
||||
return props.options.map(normalizeOption)
|
||||
})
|
||||
|
||||
const modelValue = defineModel<T>({
|
||||
set(value) {
|
||||
emits('change', value)
|
||||
return value
|
||||
}
|
||||
})
|
||||
|
||||
// FIXME: I think there's a race condition between this and the v-model event.
|
||||
// This must be triggered after the value updates, otherwise the form validates
|
||||
// the previous value.
|
||||
|
||||
Reference in New Issue
Block a user