Clicking link in host/user flyout does not refresh details panel (#209863)

## Summary

This PR fixes the issue of navigation link behaviour not updating after
first click/update.


## Testing Steps 
1. Kibana - 8.18 
2. Generate some data using data generator and alerts. 
3. Enable Risk Score
4. Go to Security -> Alerts 
5. Open Host Flyout of a host with risk score 
6. Click alert/risk summary link, then click the other one and observe
the tab on the left and content change in response 

### Screen Recordings

#### Host Selected 


https://github.com/user-attachments/assets/ac071adc-8255-496e-956b-cf727191cbe3



#### User Selected 


https://github.com/user-attachments/assets/ab10a640-964d-457f-9ff3-198c19641889

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Charlotte Alexandra Wilson 2025-02-10 13:18:14 +00:00 committed by GitHub
parent d2070ca724
commit 8c7714a611
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import React, { useMemo, useState } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import type { FlyoutPanelProps } from '@kbn/expandable-flyout';
import { EntityIdentifierFields, EntityType } from '../../../../common/entity_analytics/types';
import {
@ -52,12 +52,17 @@ export const HostDetailsPanel = ({
: EntityDetailsLeftPanelTab.RISK_INPUTS
);
useEffect(() => {
if (path?.tab && path.tab !== selectedTabId) {
setSelectedTabId(path.tab);
}
}, [path?.tab, selectedTabId]);
const [tabs] = useMemo(() => {
const isRiskScoreTabAvailable = isRiskScoreExist && name;
const riskScoreTab = isRiskScoreTabAvailable
? [getRiskInputTab({ entityName: name, entityType: EntityType.host, scopeId })]
: [];
// Determine if the Insights tab should be included
const insightsTab =
hasMisconfigurationFindings || hasVulnerabilitiesFindings || hasNonClosedAlerts