feat: add clear button to relation widget
This commit is contained in:
@ -323,6 +323,10 @@ const RelationControl: FC<WidgetControlProps<string | string[], RelationField>>
|
||||
[onChange, uniqueOptionsByValue],
|
||||
);
|
||||
|
||||
const isRequired = useMemo(() => field.required ?? true, [field.required]);
|
||||
|
||||
console.log('field.required', field.required);
|
||||
|
||||
return (
|
||||
<Field
|
||||
inputRef={ref}
|
||||
@ -363,6 +367,7 @@ const RelationControl: FC<WidgetControlProps<string | string[], RelationField>>
|
||||
value={selectedValue}
|
||||
options={uniqueOptions}
|
||||
disabled={disabled}
|
||||
required={isRequired}
|
||||
displayValue={item => {
|
||||
if (!item || Array.isArray(item)) {
|
||||
return '';
|
||||
|
@ -77,7 +77,9 @@ const SelectControl: FC<WidgetControlProps<string | number | (string | number)[]
|
||||
? !selectedValue?.length
|
||||
: isNullish(selectedValue);
|
||||
|
||||
if (field.required && isEmpty && isMultiple) {
|
||||
const isRequired = field.required ?? true;
|
||||
|
||||
if (isRequired && isEmpty && isMultiple) {
|
||||
setInternalValue([]);
|
||||
onChange([]);
|
||||
} else if (isEmpty) {
|
||||
|
Reference in New Issue
Block a user