mirror of
https://github.com/directus/directus.git
synced 2026-01-31 09:18:22 -05:00
Fix clear value for fields with default when creating an item
This commit is contained in:
@@ -118,10 +118,17 @@ export default defineComponent({
|
||||
return false;
|
||||
});
|
||||
|
||||
const defaultValue = computed(() => {
|
||||
const value = props.field.schema?.default_value;
|
||||
|
||||
if (value !== undefined) return value;
|
||||
return null;
|
||||
});
|
||||
|
||||
const _value = computed(() => {
|
||||
if (props.value !== undefined) return props.value;
|
||||
if (props.initialValue !== undefined) return props.initialValue;
|
||||
return props.field.schema?.default_value;
|
||||
return defaultValue.value;
|
||||
});
|
||||
|
||||
const { showRaw, rawValue } = useRaw();
|
||||
@@ -129,7 +136,10 @@ export default defineComponent({
|
||||
return { isDisabled, marked, _value, emitValue, showRaw, rawValue };
|
||||
|
||||
function emitValue(value: any) {
|
||||
if (isEqual(value, props.initialValue) || (value === null && props.initialValue === undefined)) {
|
||||
if (
|
||||
isEqual(value, props.initialValue) ||
|
||||
(props.initialValue === undefined && isEqual(value, defaultValue.value))
|
||||
) {
|
||||
emit('unset', props.field);
|
||||
} else {
|
||||
emit('input', value);
|
||||
|
||||
Reference in New Issue
Block a user