diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/fleet_server_instructions/steps/select_agent_policy.tsx b/x-pack/plugins/fleet/public/applications/fleet/components/fleet_server_instructions/steps/select_agent_policy.tsx index d7f2301b663f1..24099534db80c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/fleet_server_instructions/steps/select_agent_policy.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/components/fleet_server_instructions/steps/select_agent_policy.tsx @@ -26,7 +26,7 @@ export const getSelectAgentPolicyStep = ({ }): EuiStepProps => { return { title: - eligibleFleetServerPolicies.length === 0 + eligibleFleetServerPolicies.length === 0 && !policyId ? i18n.translate('xpack.fleet.fleetServerSetup.stepCreateAgentPolicyTitle', { defaultMessage: 'Create a policy for Fleet Server', }) diff --git a/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_policy_select_create.tsx b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_policy_select_create.tsx index 4dab3b054bc8d..35a65deffc70b 100644 --- a/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_policy_select_create.tsx +++ b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_policy_select_create.tsx @@ -79,9 +79,9 @@ export const SelectCreateAgentPolicy: React.FC = ({ ); useEffect(() => { - setShowCreatePolicy(regularAgentPolicies.length === 0); + setShowCreatePolicy(regularAgentPolicies.length === 0 && !selectedPolicyId); setNewName(incrementPolicyName(regularAgentPolicies, isFleetServerPolicy)); - }, [regularAgentPolicies, isFleetServerPolicy]); + }, [regularAgentPolicies, isFleetServerPolicy, selectedPolicyId]); const onAgentPolicyCreated = useCallback( async (policy: AgentPolicy | null, errorMessage?: JSX.Element) => {