From c0e6677d83abfc557cef4ae9eb042bae555fd7f6 Mon Sep 17 00:00:00 2001 From: Lola Date: Mon, 15 May 2023 15:48:22 -0400 Subject: [PATCH] [Cloud Posture]fix incorrect vuln_mgmt details in flyout (#157745) ## Summary Summarize your PR. If it involves visual changes include a screenshot or gif. Currently, after navigating any page after the first page and clicking on vulnerability, the flyout displays incorrect details. Currently, we use the `data.page`, which lists the maximum amount of vulnerabilities(500 vulnerabilities). The `vulnerabilityIndex` is set each time, a user clicks to expand vulnerability. We were currently only selecting vulnerabilities from the first page. Solution: Use `slicedPage` to get the vulnerabilities on the current page and then select vulnerability by `vulnerabilityIndex` https://github.com/elastic/kibana/assets/17135495/df682ecf-d024-45e4-84ca-d7df22a60ec4 --- .../public/pages/vulnerabilities/vulnerabilities.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/vulnerabilities.tsx b/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/vulnerabilities.tsx index 7aa56fa6d00b75..ab4cfe3d49e030 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/vulnerabilities.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/vulnerabilities.tsx @@ -116,7 +116,10 @@ const VulnerabilitiesContent = ({ dataView }: { dataView: DataView }) => { const slicedPage = usePageSlice(data?.page, pageIndex, pageSize); const invalidIndex = -1; - const selectedVulnerability = data?.page[urlQuery.vulnerabilityIndex]; + + const selectedVulnerability = useMemo(() => { + return slicedPage[urlQuery.vulnerabilityIndex]; + }, [slicedPage, urlQuery.vulnerabilityIndex]); const onCloseFlyout = () => { setUrlQuery({