From 29eae1e89278b3637c93999e8e0dc38cd575526e Mon Sep 17 00:00:00 2001 From: jennypavlova Date: Thu, 20 Jul 2023 19:20:13 +0200 Subject: [PATCH] [Infra UI] Alerts link in overview: required to click back 2 times to go back (#162312) Closes #162240 Closes #162220 Closes #162221 ## Summary This PR fixes the navigation to the alerts page issue when the back button is used - in this case, the user stays on the same page instead of going back to the previous page. This issue was found on the hosts view page after adding the 'show all' link inside the overview tab but it exists also when you navigate from the observability overview page. I tested also navigating using the menu, from observability overview and hosts view, outside of observability and the navigation works fine with the change. If there are any concerns or if I miss something I will be happy to discuss this. Before: https://github.com/elastic/kibana/assets/14139027/dc9590c9-ef7e-469c-aad4-6c6f377d9bef After: https://github.com/elastic/kibana/assets/14139027/be3d1f9a-bd27-426d-bd6e-61f5a0a206f3 --- .../containers/use_alert_search_bar_state_container.tsx | 5 ++++- x-pack/test/functional/apps/infra/hosts_view.ts | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/observability/public/components/alert_search_bar/containers/use_alert_search_bar_state_container.tsx b/x-pack/plugins/observability/public/components/alert_search_bar/containers/use_alert_search_bar_state_container.tsx index 9128fa1c3f723..841702e52b751 100644 --- a/x-pack/plugins/observability/public/components/alert_search_bar/containers/use_alert_search_bar_state_container.tsx +++ b/x-pack/plugins/observability/public/components/alert_search_bar/containers/use_alert_search_bar_state_container.tsx @@ -144,6 +144,10 @@ function syncUrlStateWithInitialContainerState( }; stateContainer.set(newState); + urlStateStorage.set(urlStorageKey, stateContainer.get(), { + replace: true, + }); + return; } else if (timefilterService.isTimeTouched()) { const { from, to } = timefilterService.getTime(); const newState = { @@ -151,7 +155,6 @@ function syncUrlStateWithInitialContainerState( rangeFrom: from, rangeTo: to, }; - stateContainer.set(newState); } else { // Reset the state container when no URL state or timefilter range is set to avoid accidentally diff --git a/x-pack/test/functional/apps/infra/hosts_view.ts b/x-pack/test/functional/apps/infra/hosts_view.ts index 27a624752288a..d909e493bf2c5 100644 --- a/x-pack/test/functional/apps/infra/hosts_view.ts +++ b/x-pack/test/functional/apps/infra/hosts_view.ts @@ -155,9 +155,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { return !!currentUrl.match(path); }); - // Failing: See https://github.com/elastic/kibana/issues/162221 - // Failing: See https://github.com/elastic/kibana/issues/162220 - describe.skip('Hosts View', function () { + describe('Hosts View', function () { before(async () => { await Promise.all([ esArchiver.load('x-pack/test/functional/es_archives/infra/alerts'),