diff --git a/README.md b/README.md index 9bd5e50..297da31 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,8 @@ PopOut Component has the following props: ```ts export interface PopoutProps { hidden?: boolean; - name?: string; + name?: string; // refers to the window.name attribute + title?: string; // refers to the document.title attribute (use this to give your new window's title bar a proper name!) onClose?: () => void; onBeforeUnload?: (evt: BeforeUnloadEvent) => string | null | undefined; children?: any; diff --git a/src/Popout.tsx b/src/Popout.tsx index 1abcfeb..4ccc6c6 100644 --- a/src/Popout.tsx +++ b/src/Popout.tsx @@ -211,6 +211,7 @@ export class Popout extends React.Component { } else { this.id = `__${name}_container__`; this.container = this.initializeChildWindow(this.id, this.child!); + this.child.document.title = getWindowTitle(this.props.title); } }; @@ -306,6 +307,10 @@ function getWindowName(name: string) { ); } +function getWindowTitle(title?: string) { + return title || ''; +} + function forEachStyleElement( nodeList: NodeList, callback: (element: HTMLElement, index?: number) => void, diff --git a/src/PopoutProps.ts b/src/PopoutProps.ts index d6826e7..b2d3ff4 100644 --- a/src/PopoutProps.ts +++ b/src/PopoutProps.ts @@ -3,6 +3,7 @@ import { WindowFeaturesOptions } from './WindowFeaturesOptions'; export interface PopoutProps { hidden?: boolean; name?: string; + title?: string; onClose?: () => void; onBeforeUnload?: (evt: BeforeUnloadEvent) => string | null | undefined; onBlocked?: () => void; diff --git a/test/MyPopout.tsx b/test/MyPopout.tsx index 1f105b2..b150556 100644 --- a/test/MyPopout.tsx +++ b/test/MyPopout.tsx @@ -19,6 +19,7 @@ export default class MyPopout extends React.Component { return (