From c26ce907a5c2f3dc0b4ae7725b259878c748a401 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko Date: Mon, 21 Nov 2022 10:34:51 +0000 Subject: [PATCH] wrapping in setTimeout --- .../components/rules/step_define_rule/index.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx index c1706636d51a5..79567c2de1e06 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx @@ -391,11 +391,15 @@ const StepDefineRuleComponent: FC = ({ }, [onSubmit]); const getData = useCallback(async () => { - // validate sometimes do not return correct validation state of form - // workaround is to call it twice - await validate(); - const isValid = await validate(); - + // validate doesn't return actual state of form + // more details here: https://github.com/elastic/kibana/issues/144322#issuecomment-1321838136 + // wrapping in setTimeout is a workaround until solution within forms-lib can be found + const isValid = await new Promise((resolve) => { + setTimeout(async () => { + const valid = await validate(); + resolve(valid); + }, 0); + }); return { isValid, data: {