Skip to content

Commit

Permalink
wrapping in setTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliidm committed Nov 21, 2022
1 parent d900adf commit c26ce90
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,15 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({
}, [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<boolean>((resolve) => {
setTimeout(async () => {
const valid = await validate();
resolve(valid);
}, 0);
});
return {
isValid,
data: {
Expand Down

0 comments on commit c26ce90

Please sign in to comment.