@centreon/ui 24.4.72 → 24.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "24.4.72",
3
+ "version": "24.5.0",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -1,5 +1,6 @@
1
1
  import { Dispatch, SetStateAction, useEffect } from 'react';
2
2
 
3
+ import { isNil } from 'ramda';
3
4
  import { useLocation } from 'react-router-dom';
4
5
 
5
6
  interface Props {
@@ -14,21 +15,23 @@ const useCloseOnLegacyPage = ({ setToggled }: Props): void => {
14
15
  };
15
16
 
16
17
  useEffect(() => {
17
- const iframe = document.getElementById('main-content') as HTMLIFrameElement;
18
+ const iframe = document.getElementById(
19
+ 'main-content'
20
+ ) as HTMLIFrameElement | null;
18
21
 
19
- if (!isLegacyRoute) {
22
+ if (!isLegacyRoute || isNil(iframe)) {
20
23
  return () => undefined;
21
24
  }
22
25
 
23
26
  const closeSubMenuOnLegacyPage = (): void => {
24
- iframe.contentWindow?.document?.addEventListener('click', closeSubMenu);
27
+ iframe?.contentWindow?.document?.addEventListener('click', closeSubMenu);
25
28
  };
26
29
 
27
- iframe.addEventListener('load', closeSubMenuOnLegacyPage);
30
+ iframe?.addEventListener('load', closeSubMenuOnLegacyPage);
28
31
 
29
32
  return () => {
30
- iframe.removeEventListener('load', closeSubMenuOnLegacyPage);
31
- iframe.contentWindow?.document?.removeEventListener(
33
+ iframe?.removeEventListener('load', closeSubMenuOnLegacyPage);
34
+ iframe?.contentWindow?.document?.removeEventListener(
32
35
  'click',
33
36
  closeSubMenu
34
37
  );