@linzjs/windows 4.1.2 → 4.1.3

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.
@@ -6,13 +6,14 @@ import { PanelInstanceContext } from "./PanelInstanceContext";
6
6
  import { PanelsContext } from "./PanelsContext";
7
7
  import { PopoutWindow } from "./PopoutWindow";
8
8
  import clsx from "clsx";
9
- import { PropsWithChildren, ReactElement, useContext, useEffect, useMemo } from "react";
9
+ import { PropsWithChildren, ReactElement, useContext, useEffect, useMemo, useRef } from "react";
10
10
  import { createPortal } from "react-dom";
11
11
  import { PopinWindow } from "./PopinWIndow";
12
12
  import { PanelProps } from "./types/PanelProps";
13
13
  import { useConstFunction } from "../common";
14
14
 
15
15
  export const Panel = (props: PanelProps): ReactElement => {
16
+ const panelRef = useRef<HTMLDivElement>(null);
16
17
  const { title, size = { width: 320, height: 200 }, className, children, onClose } = props;
17
18
 
18
19
  const { dockElements, nextStackPosition } = useContext(PanelsContext);
@@ -30,6 +31,16 @@ export const Panel = (props: PanelProps): ReactElement => {
30
31
  setTitle(title);
31
32
  }, [setTitle, title]);
32
33
 
34
+ // We only want to update the title when it changes
35
+ useEffect(() => {
36
+ if (panelRef.current) {
37
+ const doc = panelRef.current.ownerDocument;
38
+ if (doc) {
39
+ doc.title = title;
40
+ }
41
+ }
42
+ }, [title]);
43
+
33
44
  const dockElement = docked && dockId && dockElements[dockId];
34
45
 
35
46
  /**
@@ -55,6 +66,7 @@ export const Panel = (props: PanelProps): ReactElement => {
55
66
  ) : panelPoppedOut ? (
56
67
  <PopoutWindow name={uniqueId} title={title} size={size}>
57
68
  <div
69
+ ref={panelRef}
58
70
  style={{
59
71
  display: "flex",
60
72
  flexDirection: "column",
@@ -3,7 +3,7 @@ import { makePopoutId, popoutWindowDivId } from "./generateId";
3
3
  import { copyStyleSheets, observeStyleSheetChanges } from "./handleStyleSheetsChanges";
4
4
  import createCache from "@emotion/cache";
5
5
  import { CacheProvider } from "@emotion/react";
6
- import { Dispatch, ReactElement, ReactNode, SetStateAction, useContext, useEffect, useRef, useState } from "react";
6
+ import { Dispatch, ReactElement, ReactNode, SetStateAction, useContext, useEffect, useState } from "react";
7
7
  import ReactDOM from "react-dom";
8
8
  import { useRestoreStateFrom, useSaveStateIn } from "./usePanelStateHandler";
9
9
  import { PanelPosition, PanelSize } from "./types";
@@ -128,18 +128,9 @@ export const PopoutWindow = ({
128
128
  }: PopoutWindowProps): ReactElement | null => {
129
129
  const { setPanelWindow } = useContext(PanelInstanceContext);
130
130
 
131
- const extWindow = useRef<Window | null>(null);
132
-
133
131
  const [containerElement, setContainerElement] = useState<HTMLElement>();
134
132
  const [headElement, setHeadElement] = useState<HTMLElement>();
135
133
 
136
- // We only want to update the title when it changes
137
- useEffect(() => {
138
- if (extWindow.current) {
139
- extWindow.current.document.title = title;
140
- }
141
- }, [title]);
142
-
143
134
  const savedState = useRestoreStateFrom({ panelPoppedOut: true, uniqueId: name });
144
135
 
145
136
  const panelPosition = savedState?.panelPosition ?? { x: 300, y: 200 };
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "popout"
14
14
  ],
15
15
  "main": "./dist/index.ts",
16
- "version": "4.1.2",
16
+ "version": "4.1.3",
17
17
  "peerDependencies": {
18
18
  "@linzjs/lui": ">=21",
19
19
  "lodash-es": ">=4",