Skip to content

Commit

Permalink
Handle index validation when initial loading
Browse files Browse the repository at this point in the history
  • Loading branch information
kdelemme committed Jan 12, 2023
1 parent c5a86e0 commit 00d9781
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function SloEditFormDefinitionCustomKql({ control, trigger }: Props) {
required: true,
validate: (value) => indices.some((index) => valueMatchIndex(value, index.name)),
}}
render={({ field }) => (
render={({ field, fieldState }) => (
<EuiSuggest
fullWidth
isClearable
Expand All @@ -73,7 +73,10 @@ export function SloEditFormDefinitionCustomKql({ control, trigger }: Props) {
onItemClick={({ label }) => {
field.onChange(label);
}}
isInvalid={!indicesNames.some((index) => valueMatchIndex(field.value, index.label))}
isInvalid={
fieldState.isDirty &&
!indicesNames.some((index) => valueMatchIndex(field.value, index.label))
}
placeholder={i18n.translate(
'xpack.observability.slos.sloEdit.sloDefinition.customKql.index.selectIndex',
{
Expand Down

0 comments on commit 00d9781

Please sign in to comment.