[8.17] fix `Cannot read properties of null (reading 'closed')` when chrome is remounted (#210075) (#210098)

# Backport

This will backport the following commits from `main` to `8.17`:
- [fix `Cannot read properties of null (reading
'closed')` when chrome is remounted
(#210075)](https://github.com/elastic/kibana/pull/210075)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Anton
Dosov","email":"anton.dosov@elastic.co"},"sourceCommit":{"committedDate":"2025-02-06T19:02:59Z","message":"fix
`Cannot read properties of null (reading 'closed')` when chrome is
remounted
(#210075)","sha":"cd398d939462ebeb73f05c4fdd1d88db349eacf8","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","backport:prev-major","v9.1.0"],"title":"fix
`Cannot read properties of null (reading 'closed')` when chrome is
remounted
","number":210075,"url":"https://github.com/elastic/kibana/pull/210075","mergeCommit":{"message":"fix
`Cannot read properties of null (reading 'closed')` when chrome is
remounted
(#210075)","sha":"cd398d939462ebeb73f05c4fdd1d88db349eacf8"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/210075","number":210075,"mergeCommit":{"message":"fix
`Cannot read properties of null (reading 'closed')` when chrome is
remounted
(#210075)","sha":"cd398d939462ebeb73f05c4fdd1d88db349eacf8"}}]}]
BACKPORT-->

Co-authored-by: Anton Dosov <anton.dosov@elastic.co>
This commit is contained in:
Kibana Machine 2025-02-07 08:00:55 +11:00 committed by GitHub
parent c2417d3b52
commit 7359e5e0bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -55,7 +55,7 @@ export function useIsNavControlVisible({ coreStart, pluginsStart }: UseIsNavCont
},
});
return appSubscription.unsubscribe;
return () => appSubscription.unsubscribe();
}, [currentAppId$, applications$, aiAssistantManagementSelection.aiAssistantType$]);
return {