Fix EntityPicker allowing clear value when required #16993

Signed-off-by: Martin Morales <morales-martin@outlook.com>
This commit is contained in:
Martin Morales
2023-03-23 18:47:05 -05:00
parent b268dab386
commit b71f58d7d8
2 changed files with 7 additions and 1 deletions
@@ -96,7 +96,8 @@ export const EntityPicker = (props: EntityPickerProps) => {
(_: any, ref: string | Entity | null, reason: AutocompleteChangeReason) => {
// ref can either be a string from free solo entry or
if (typeof ref !== 'string') {
onChange(ref ? stringifyEntityRef(ref as Entity) : '');
// if ref does not exist: pass 'undefined' to trigger validation for non-free solo entries
onChange(ref ? stringifyEntityRef(ref as Entity) : undefined);
} else {
if (reason === 'blur' || reason === 'create-option') {
// Add in default namespace, etc.