diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/threshold/expression.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/threshold/expression.tsx index 96513f0563ad0..5bbec1221a3ac 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/threshold/expression.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/threshold/expression.tsx @@ -145,6 +145,13 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent { + setIndexPopoverOpen(false); + if (timeField === undefined) { + setAlertParams('timeField', ''); + } + }; + useEffect(() => { const indexPatternsFunction = async () => { setIndexPatterns(await getIndexPatterns()); @@ -293,18 +300,16 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent 0 ? index.join(' ') : firstFieldOption.text} isActive={indexPopoverOpen} onClick={() => { setIndexPopoverOpen(true); }} - color={index ? 'secondary' : 'danger'} + color={index && index.length > 0 && timeField !== '' ? 'secondary' : 'danger'} /> } isOpen={indexPopoverOpen} - closePopover={() => { - setIndexPopoverOpen(false); - }} + closePopover={closeIndexPopover} ownFocus withTitle anchorPosition="downLeft" @@ -331,9 +336,7 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent { - setIndexPopoverOpen(false); - }} + onClick={closeIndexPopover} />