diff --git a/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/form.tsx b/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/form.tsx index ec2a3ffe0936d..a9d1572ba5cba 100644 --- a/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/form.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/form.tsx @@ -66,9 +66,8 @@ export const HostIsolationExceptionsForm: React.FC<{ const [hasNameError, setHasNameError] = useState(!exception.name); const [hasIpError, setHasIpError] = useState(!ipEntry.value); - const [isGlobal, setIsGlobal] = useState(isGlobalPolicyEffected(exception.tags)); const [selectedPolicies, setSelectedPolicies] = useState({ - isGlobal, + isGlobal: isGlobalPolicyEffected(exception.tags), selected: [], }); @@ -120,12 +119,13 @@ export const HostIsolationExceptionsForm: React.FC<{ const handlePolicySelectChange: EffectedPolicySelectProps['onChange'] = useCallback( (selection) => { - setIsGlobal(selection.isGlobal); - // preseve the previous selection between global and not global toggle - if (!selection.isGlobal) { - setSelectedPolicies(() => selection); + if (selection.isGlobal) { + setSelectedPolicies({ isGlobal: true, selected: selection.selected }); + } else { + setSelectedPolicies(selection); } + onChange({ tags: getArtifactTagsByEffectedPolicySelection( selection, @@ -251,7 +251,7 @@ export const HostIsolationExceptionsForm: React.FC<{