Fix EntityPicker allowing clear value when required #16993
Signed-off-by: Martin Morales <morales-martin@outlook.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder': minor
|
||||
---
|
||||
|
||||
Fixed bug in EntityPicker component that allowed for empty values when field is required. This bug occurs only after a user fills the EntityPicker field, clears it, and then continues to the next form step.
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user