Skip to content

Commit 2ac2d80

Browse files
committed
fix: adjust fullscreen target
1 parent 18d15bc commit 2ac2d80

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

packages/instrument-renderer/src/components/InteractiveContent/InteractiveContent.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useEffect, useState } from 'react';
1+
import React, { useCallback, useEffect, useRef, useState } from 'react';
22

33
import { Button, Separator } from '@douglasneuroinformatics/libui/components';
44
import { type Theme, useTheme, useTranslation } from '@douglasneuroinformatics/libui/hooks';
@@ -21,6 +21,7 @@ export const InteractiveContent = React.memo<InteractiveContentProps>(function I
2121
const { changeLanguage } = useTranslation();
2222
const [_, updateTheme] = useTheme();
2323
const [scale, setScale] = useState(100);
24+
const iFrameRef = useRef<HTMLIFrameElement>(null);
2425

2526
const handleChangeLanguageEvent = useCallback(
2627
(event: CustomEvent<Language>) => {
@@ -56,8 +57,8 @@ export const InteractiveContent = React.memo<InteractiveContentProps>(function I
5657

5758
const handleToggleFullScreen = async () => {
5859
if (!document.fullscreenElement) {
59-
await document.documentElement.requestFullscreen();
60-
} else if (document.exitFullscreen) {
60+
await iFrameRef.current?.requestFullscreen();
61+
} else {
6162
await document.exitFullscreen();
6263
}
6364
};
@@ -109,6 +110,7 @@ export const InteractiveContent = React.memo<InteractiveContentProps>(function I
109110
className="origin-top-left"
110111
data-bundle={bundle}
111112
name="interactive-instrument"
113+
ref={iFrameRef}
112114
srcDoc={`<script type="module">${bootstrapScript}</script>`}
113115
style={{ height: dimensions, scale: `${scale}%`, width: dimensions }}
114116
title="Open Data Capture - Interactive Instrument"

0 commit comments

Comments
 (0)