feat: add new issue trigger in GitHub
This commit is contained in:
@@ -11,7 +11,7 @@ interface ControlledAutocompleteProps extends AutocompleteProps<IFieldDropdownOp
|
||||
description?: string;
|
||||
}
|
||||
|
||||
const getOption = (options: readonly IFieldDropdownOption[], value: string) => options.find(option => option.value === value);
|
||||
const getOption = (options: readonly IFieldDropdownOption[], value: string) => options.find(option => option.value === value) || null;
|
||||
|
||||
function ControlledAutocomplete(props: ControlledAutocompleteProps): React.ReactElement {
|
||||
const { control } = useFormContext();
|
||||
@@ -45,7 +45,7 @@ function ControlledAutocomplete(props: ControlledAutocompleteProps): React.React
|
||||
value={getOption(options, field.value)}
|
||||
onChange={(event, selectedOption, reason, details) => {
|
||||
const typedSelectedOption = selectedOption as IFieldDropdownOption;
|
||||
if (Object.prototype.hasOwnProperty.call(typedSelectedOption, 'value')) {
|
||||
if (typedSelectedOption !== null && Object.prototype.hasOwnProperty.call(typedSelectedOption, 'value')) {
|
||||
controllerOnChange(typedSelectedOption.value);
|
||||
} else {
|
||||
controllerOnChange(typedSelectedOption);
|
||||
|
@@ -69,11 +69,13 @@ function generateValidationSchema(substeps: ISubstep[]) {
|
||||
// if the field depends on another field, add the dependsOn required validation
|
||||
if (dependsOn?.length > 0) {
|
||||
for (const dependsOnKey of dependsOn) {
|
||||
const missingDependencyValueMessage = `We're having trouble loading '${key}' data as required field '${dependsOnKey}' is missing.`;
|
||||
|
||||
// TODO: make `dependsOnKey` agnostic to the field. However, nested validation schema is not supported.
|
||||
// So the fields under the `parameters` key are subject to their siblings only and thus, `parameters.` is removed.
|
||||
substepArgumentValidations[key] = substepArgumentValidations[key].when(`${dependsOnKey.replace('parameters.', '')}`, {
|
||||
is: (value: string) => Boolean(value) === false,
|
||||
then: (schema) => schema.required(`We're having trouble loading '${key}' data as required field '${dependsOnKey}' is missing.`),
|
||||
then: (schema) => schema.notOneOf([''], missingDependencyValueMessage).required(missingDependencyValueMessage),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user