Skip to content

Commit 1cde991

Browse files
committed
feat: SidePanelDocumentation - open in new tab btn - current link, style updates
1 parent 45dbd00 commit 1cde991

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/components/common/SidePanel/SidePanelDocumentation.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useRef } from 'react'
2+
13
import {
24
Button,
35
ButtonComponentType,
@@ -18,12 +20,15 @@ export const SidePanelDocumentation = ({ onClose }: SidePanelDocumentationProps)
1820
sidePanelConfig: { docLink },
1921
} = useMainContext()
2022

23+
// REFS
24+
const iframeRef = useRef<HTMLIFrameElement | null>(null)
25+
2126
// CONSTANTS
2227
const iframeSrc = `${docLink}&theme=${appTheme}`
2328

2429
return (
2530
<>
26-
<div className="px-16 pt-14 pb-13 border__primary--bottom flex dc__gap-12">
31+
<div className="px-16 pt-12 pb-11 border__primary--bottom flex dc__gap-12">
2732
<Icon name="ic-book-open" color="N900" />
2833
<h2 className="m-0 fs-16 lh-1-5 fw-6 cn-9 flex-grow-1">Documentation</h2>
2934
<div className="flex dc__gap-8">
@@ -36,7 +41,10 @@ export const SidePanelDocumentation = ({ onClose }: SidePanelDocumentationProps)
3641
size={ComponentSizeType.xs}
3742
component={ButtonComponentType.anchor}
3843
anchorProps={{
39-
href: docLink,
44+
href:
45+
iframeRef.current?.contentDocument?.referrer ??
46+
iframeRef.current?.contentWindow?.location?.href ??
47+
docLink,
4048
}}
4149
/>
4250
<Button
@@ -55,14 +63,15 @@ export const SidePanelDocumentation = ({ onClose }: SidePanelDocumentationProps)
5563
{docLink && (
5664
<iframe
5765
key={iframeSrc}
66+
ref={iframeRef}
5867
title="side-panel-documentation"
5968
loading="lazy"
6069
className="dc__no-border"
6170
src={iframeSrc}
6271
width="100%"
6372
height="100%"
6473
allow="clipboard-read; clipboard-write"
65-
sandbox="allow-same-origin allow-scripts"
74+
sandbox="allow-same-origin allow-scripts allow-popups"
6675
referrerPolicy="no-referrer"
6776
/>
6877
)}

0 commit comments

Comments
 (0)